Mono-Doc¶
This file holds the entire API reference in a single page; should that be your preference.
Clients¶
Client ¶
Bases: processors.AutoModEvents, processors.ChannelEvents, processors.GuildEvents, processors.MemberEvents, processors.MessageEvents, processors.ReactionEvents, processors.RoleEvents, processors.StageEvents, processors.ThreadEvents, processors.UserEvents, processors.VoiceEvents
The bot client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intents | Union[int, Intents] | The intents to use | Intents.DEFAULT |
default_prefix | str | Iterable[str] | The default prefix (or prefixes) to use for prefixed commands. Defaults to your bot being mentioned. | MENTION_PREFIX |
generate_prefixes | Absent[Callable[..., Coroutine]] | A coroutine that returns a string or an iterable of strings to determine prefixes. | MISSING |
status | Status | The status the bot should log in with (IE ONLINE, DND, IDLE) | Status.ONLINE |
activity | Union[Activity, str] | The activity the bot should log in "playing" | None |
sync_interactions | bool | Should application commands be synced with discord? | True |
delete_unused_application_cmds | bool | Delete any commands from discord that aren't implemented in this client | False |
enforce_interaction_perms | bool | Enforce discord application command permissions, locally | True |
fetch_members | bool | Should the client fetch members from guilds upon startup (this will delay the client being ready) | False |
send_command_tracebacks | bool | Automatically send uncaught tracebacks if a command throws an exception | True |
auto_defer | Absent[Union[AutoDefer, bool]] | MISSING | |
interaction_context | Type[InteractionContext] | Type[InteractionContext]: InteractionContext: The object to instantiate for Interaction Context | InteractionContext |
prefixed_context | Type[PrefixedContext] | Type[PrefixedContext]: The object to instantiate for Prefixed Context | PrefixedContext |
component_context | Type[ComponentContext] | Type[ComponentContext]: The object to instantiate for Component Context | ComponentContext |
autocomplete_context | Type[AutocompleteContext] | Type[AutocompleteContext]: The object to instantiate for Autocomplete Context | AutocompleteContext |
modal_context | Type[ModalContext] | Type[ModalContext]: The object to instantiate for Modal Context | ModalContext |
hybrid_context | Type[HybridContext] | Type[HybridContext]: The object to instantiate for Hybrid Context | HybridContext |
total_shards | int | The total number of shards in use | 1 |
shard_id | int | The zero based int ID of this shard | 0 |
debug_scope | Absent[Snowflake_Type] | Force all application commands to be registered within this scope | MISSING |
basic_logging | bool | Utilise basic logging to output library data to console. Do not use in combination with | False |
logging_level | int | The level of logging to use for basic_logging. Do not use in combination with | logging.INFO |
logger | logging.Logger | The logger NAFF should use. Do not use in combination with | logger |
Optionally, you can configure the caches here, by specifying the name of the cache, followed by a dict-style object to use. It is recommended to use smart_cache.create_cache to configure the cache here. as an example, this is a recommended attribute message_cache=create_cache(250, 50),
Intents Note
By default, all non-privileged intents will be enabled
Caching Note
Setting a message cache hard limit to None is not recommended, as it could result in extremely high memory usage, we suggest a sane limit.
Source code in naff/client/client.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 | |
logger = logger instance-attribute ¶
The logger NAFF should use. Do not use in combination with Client.basic_logging and Client.logging_level.
Note
Different loggers with multiple clients are not supported
sync_interactions: bool = sync_interactions instance-attribute ¶
Should application commands be synced
del_unused_app_cmd: bool = delete_unused_application_cmds instance-attribute ¶
Should unused application commands be deleted?
sync_ext: bool = sync_ext instance-attribute ¶
Should we sync whenever a extension is (un)loaded
debug_scope = to_snowflake(debug_scope) if debug_scope is not MISSING else MISSING instance-attribute ¶
Sync global commands as guild for quicker command updates during debug
default_prefix = default_prefix instance-attribute ¶
The default prefix to be used for prefixed commands
send_command_tracebacks: bool = send_command_tracebacks instance-attribute ¶
Should the traceback of command errors be sent in reply to the command invocation
auto_defer = auto_defer instance-attribute ¶
A system to automatically defer commands after a set duration
http: HTTPClient = HTTPClient() instance-attribute ¶
The HTTP client to use when interacting with discord endpoints
interaction_context: Type[InteractionContext] = interaction_context instance-attribute ¶
The object to instantiate for Interaction Context
prefixed_context: Type[PrefixedContext] = prefixed_context instance-attribute ¶
The object to instantiate for Prefixed Context
component_context: Type[ComponentContext] = component_context instance-attribute ¶
The object to instantiate for Component Context
autocomplete_context: Type[AutocompleteContext] = autocomplete_context instance-attribute ¶
The object to instantiate for Autocomplete Context
modal_context: Type[ModalContext] = modal_context instance-attribute ¶
The object to instantiate for Modal Context
hybrid_context: Type[HybridContext] = hybrid_context instance-attribute ¶
The object to instantiate for Hybrid Context
guild_event_timeout = 3 instance-attribute ¶
How long to wait for guilds to be cached
fetch_members = fetch_members instance-attribute ¶
Fetch the full members list of all guilds on startup
prefixed_commands: Dict[str, PrefixedCommand] = {} instance-attribute ¶
A dictionary of registered prefixed commands: {name: command}
interactions: Dict[Snowflake_Type, Dict[str, InteractionCommand]] = {} instance-attribute ¶
A dictionary of registered application commands: {cmd_id: command}
ext = {} instance-attribute ¶
A dictionary of mounted ext
async_startup_tasks: list[Coroutine] = [] instance-attribute ¶
A list of coroutines to run during startup
is_closed() property ¶
Returns True if the bot has closed.
Source code in naff/client/client.py
400 401 402 403 | |
is_ready() property ¶
Returns True if the bot is ready.
Source code in naff/client/client.py
405 406 407 408 | |
latency() property ¶
Returns the latency of the websocket connection.
Source code in naff/client/client.py
410 411 412 413 | |
average_latency() property ¶
Returns the average latency of the websocket connection.
Source code in naff/client/client.py
415 416 417 418 | |
start_time() property ¶
The start time of the bot.
Source code in naff/client/client.py
420 421 422 423 | |
gateway_started() property ¶
Returns if the gateway has been started.
Source code in naff/client/client.py
425 426 427 428 | |
user() property ¶
Returns the bot's user.
Source code in naff/client/client.py
430 431 432 433 | |
app() property ¶
Returns the bots application.
Source code in naff/client/client.py
435 436 437 438 | |
owner() property ¶
Returns the bot's owner'.
Source code in naff/client/client.py
440 441 442 443 444 445 446 | |
owners() property ¶
Returns the bot's owners as declared via client.owner_ids.
Source code in naff/client/client.py
448 449 450 451 | |
guilds() property ¶
Returns a list of all guilds the bot is in.
Source code in naff/client/client.py
453 454 455 456 | |
status() property ¶
Get the status of the bot.
IE online, afk, dnd
Source code in naff/client/client.py
458 459 460 461 462 463 464 465 466 | |
activity() property ¶
Get the activity of the bot.
Source code in naff/client/client.py
468 469 470 471 | |
application_commands() property ¶
A list of all application commands registered within the bot.
Source code in naff/client/client.py
473 474 475 476 477 478 479 480 | |
ws() property ¶
Returns the websocket client.
Source code in naff/client/client.py
482 483 484 485 | |
generate_prefixes(bot, message) async ¶
A method to get the bot's default_prefix, can be overridden to add dynamic prefixes.
Note
To easily override this method, simply use the generate_prefixes parameter when instantiating the client
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bot | Client | A reference to the client | required |
message | Message | A message to determine the prefix from. | required |
Example
1 2 3 4 5 6 | |
Returns:
| Type | Description |
|---|---|
str | Iterable[str] | A string or an iterable of strings to use as a prefix. By default, this will return |
Source code in naff/client/client.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |
default_error_handler(source, error) staticmethod ¶
The default error logging behaviour.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source | str | The source of this error | required |
error | BaseException | The exception itself | required |
Source code in naff/client/client.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 | |
on_error(source, error, *args, **kwargs) async ¶
Catches all errors dispatched by the library.
By default it will format and print them to console
Override this to change error handling behaviour
Source code in naff/client/client.py
597 598 599 600 601 602 603 604 605 606 | |
on_command_error(ctx, error, *args, **kwargs) async ¶
Catches all errors dispatched by commands.
By default it will call Client.on_error
Override this to change error handling behavior
Source code in naff/client/client.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | |
on_command(ctx) async ¶
Called after any command is ran.
By default, it will simply log the command, override this to change that behaviour
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context of the command that was called | required |
Source code in naff/client/client.py
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
on_component_error(ctx, error, *args, **kwargs) async ¶
Catches all errors dispatched by components.
By default it will call Naff.on_error
Override this to change error handling behavior
Source code in naff/client/client.py
674 675 676 677 678 679 680 681 682 683 | |
on_component(ctx) async ¶
Called after any component callback is ran.
By default, it will simply log the component use, override this to change that behaviour
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | ComponentContext | The context of the component that was called | required |
Source code in naff/client/client.py
685 686 687 688 689 690 691 692 693 694 695 696 | |
on_autocomplete_error(ctx, error, *args, **kwargs) async ¶
Catches all errors dispatched by autocompletion options.
By default it will call Naff.on_error
Override this to change error handling behavior
Source code in naff/client/client.py
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | |
on_autocomplete(ctx) async ¶
Called after any autocomplete callback is ran.
By default, it will simply log the autocomplete callback, override this to change that behaviour
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | AutocompleteContext | The context of the command that was called | required |
Source code in naff/client/client.py
717 718 719 720 721 722 723 724 725 726 727 728 | |
login(token) async ¶
Login to discord via http.
Note
You will need to run Naff.start_gateway() before you start receiving gateway events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token | str | Your bot's token | required |
Source code in naff/client/client.py
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | |
astart(token) async ¶
Asynchronous method to start the bot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token | str | Your bot's token | required |
Source code in naff/client/client.py
832 833 834 835 836 837 838 839 840 841 842 843 | |
start(token) ¶
Start the bot.
info
This is the recommended method to start the bot
Source code in naff/client/client.py
845 846 847 848 849 850 851 852 853 854 855 856 857 | |
start_gateway() async ¶
Starts the gateway connection.
Source code in naff/client/client.py
859 860 861 862 863 864 | |
stop() async ¶
Shutdown the bot.
Source code in naff/client/client.py
866 867 868 869 870 871 | |
dispatch(event, *args, **kwargs) ¶
Dispatch an event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event | events.BaseEvent | The event to be dispatched. | required |
Source code in naff/client/client.py
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | |
wait_until_ready() async ¶
Waits for the client to become ready.
Source code in naff/client/client.py
904 905 906 | |
wait_for(event, checks=MISSING, timeout=None) ¶
Waits for a WebSocket event to be dispatched.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event | Union[str, BaseEvent] | The name of event to wait. | required |
checks | Absent[Optional[Callable[..., bool]]] | A predicate to check what to wait for. | MISSING |
timeout | Optional[float] | The number of seconds to wait before timing out. | None |
Returns:
| Type | Description |
|---|---|
Any | The event object. |
Source code in naff/client/client.py
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 | |
wait_for_modal(modal, author=None, timeout=None) async ¶
Wait for a modal response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modal | Modal | The modal we're waiting for. | required |
author | Optional[Snowflake_Type] | The user we're waiting for to reply | None |
timeout | Optional[float] | A timeout in seconds to stop waiting | None |
Returns:
| Type | Description |
|---|---|
ModalContext | The context of the modal response |
Raises:
| Type | Description |
|---|---|
asyncio.TimeoutError | if no response is received that satisfies the predicate before timeout seconds have passed |
Source code in naff/client/client.py
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 | |
wait_for_component(messages=None, components=None, check=None, timeout=None) async ¶
Waits for a component to be sent to the bot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages | Union[Message, int, list] | The message object to check for. | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to wait for. | None |
check | Optional[Callable] | A predicate to check what to wait for. | None |
timeout | Optional[float] | The number of seconds to wait before timing out. | None |
Returns:
| Type | Description |
|---|---|
Component |
|
Raises:
| Type | Description |
|---|---|
asyncio.TimeoutError | if timed out |
Source code in naff/client/client.py
969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 | |
listen(event_name=MISSING) ¶
A decorator to be used in situations that Naff can't automatically hook your listeners. Ideally, the standard listen decorator should be used, not this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name | Absent[str] | The event name to use, if not the coroutine name | MISSING |
Returns:
| Type | Description |
|---|---|
Listener | A listener that can be used to hook into the event. |
Source code in naff/client/client.py
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | |
add_event_processor(event_name=MISSING) ¶
A decorator to be used to add event processors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name | Absent[str] | The event name to use, if not the coroutine name | MISSING |
Returns:
| Type | Description |
|---|---|
Callable[..., Coroutine] | A function that can be used to hook into the event. |
Source code in naff/client/client.py
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 | |
add_listener(listener) ¶
Add a listener for an event, if no event is passed, one is determined.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
listener | Listener | The listener to add to the client | required |
Source code in naff/client/client.py
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 | |
add_interaction(command) ¶
Add a slash command to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command | InteractionCommand | The command to add | required |
Source code in naff/client/client.py
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | |
add_prefixed_command(command) ¶
Add a prefixed command to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command | PrefixedCommand | The command to add | required |
Source code in naff/client/client.py
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 | |
add_component_callback(command) ¶
Add a component callback to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command | ComponentCommand | The command to add | required |
Source code in naff/client/client.py
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 | |
add_modal_callback(command) ¶
Add a modal callback to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command | ModalCommand | The command to add | required |
Source code in naff/client/client.py
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 | |
synchronise_interactions(*, scopes=MISSING, delete_commands=MISSING) async ¶
Synchronise registered interactions with discord.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scopes | Sequence[Snowflake_Type] | Optionally specify which scopes are to be synced | MISSING |
delete_commands | Absent[bool] | Override the client setting and delete commands | MISSING |
Source code in naff/client/client.py
1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 | |
get_application_cmd_by_id(cmd_id) ¶
Get a application command from the internal cache by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd_id | Snowflake_Type | The ID of the command | required |
Returns:
| Type | Description |
|---|---|
Optional[InteractionCommand] | The command, if one with the given ID exists internally, otherwise None |
Source code in naff/client/client.py
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 | |
get_context(data, interaction=False) async ¶
Return a context object based on data passed.
Note
If you want to use custom context objects, this is the method to override. Your replacement must take the same arguments as this, and return a Context-like object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data | InteractionData | dict | Message | The data of the event | required |
interaction | bool | Is this an interaction or not? | False |
Returns:
| Type | Description |
|---|---|
ComponentContext | AutocompleteContext | ModalContext | InteractionContext | PrefixedContext | Context object |
Source code in naff/client/client.py
1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 | |
get_extensions(name) ¶
Get all ext with a name or extension name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the extension, or the name of it's extension | required |
Returns:
| Type | Description |
|---|---|
list[Extension] | List of Extensions |
Source code in naff/client/client.py
1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 | |
get_ext(name) ¶
Get a extension with a name or extension name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the extension, or the name of it's extension | required |
Returns:
| Type | Description |
|---|---|
Extension | None | A extension, if found |
Source code in naff/client/client.py
1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 | |
load_extension(name, package=None, **load_kwargs) ¶
Load an extension with given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the extension. | required |
package | str | None | The package the extension is in | None |
**load_kwargs | Any | The auto-filled mapping of the load keyword arguments | {} |
Source code in naff/client/client.py
1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 | |
unload_extension(name, package=None, **unload_kwargs) ¶
Unload an extension with given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the extension. | required |
package | str | None | The package the extension is in | None |
**unload_kwargs | Any | The auto-filled mapping of the unload keyword arguments | {} |
Source code in naff/client/client.py
1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 | |
reload_extension(name, package=None, *, load_kwargs=None, unload_kwargs=None) ¶
Helper method to reload an extension. Simply unloads, then loads the extension with given arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the extension. | required |
package | str | None | The package the extension is in | None |
load_kwargs | Any | The manually-filled mapping of the load keyword arguments | None |
unload_kwargs | Any | The manually-filled mapping of the unload keyword arguments | None |
Source code in naff/client/client.py
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 | |
fetch_guild(guild_id) async ¶
Fetch a guild.
Note
This method is an alias for the cache which will either return a cached object, or query discord for the object if its not already cached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild to get | required |
Returns:
| Type | Description |
|---|---|
Optional[Guild] | Guild Object if found, otherwise None |
Source code in naff/client/client.py
1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 | |
get_guild(guild_id) ¶
Get a guild.
Note
This method is an alias for the cache which will return a cached object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild to get | required |
Returns:
| Type | Description |
|---|---|
Optional[Guild] | Guild Object if found, otherwise None |
Source code in naff/client/client.py
1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 | |
create_guild_from_template(template_code, name, icon=MISSING) async ¶
Creates a new guild based on a template.
Note
This endpoint can only be used by bots in less than 10 guilds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_code | Union[GuildTemplate, str] | The code of the template to use. | required |
name | str | The name of the guild (2-100 characters) | required |
icon | Absent[UPLOADABLE_TYPE] | Location or File of icon to set | MISSING |
Returns:
| Type | Description |
|---|---|
Optional[Guild] | The newly created guild object |
Source code in naff/client/client.py
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 | |
fetch_channel(channel_id) async ¶
Fetch a channel.
Note
This method is an alias for the cache which will either return a cached object, or query discord for the object if its not already cached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get | required |
Returns:
| Type | Description |
|---|---|
Optional[TYPE_ALL_CHANNEL] | Channel Object if found, otherwise None |
Source code in naff/client/client.py
1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 | |
get_channel(channel_id) ¶
Get a channel.
Note
This method is an alias for the cache which will return a cached object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get | required |
Returns:
| Type | Description |
|---|---|
Optional[TYPE_ALL_CHANNEL] | Channel Object if found, otherwise None |
Source code in naff/client/client.py
1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 | |
fetch_user(user_id) async ¶
Fetch a user.
Note
This method is an alias for the cache which will either return a cached object, or query discord for the object if its not already cached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id | Snowflake_Type | The ID of the user to get | required |
Returns:
| Type | Description |
|---|---|
Optional[User] | User Object if found, otherwise None |
Source code in naff/client/client.py
1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 | |
get_user(user_id) ¶
Get a user.
Note
This method is an alias for the cache which will return a cached object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id | Snowflake_Type | The ID of the user to get | required |
Returns:
| Type | Description |
|---|---|
Optional[User] | User Object if found, otherwise None |
Source code in naff/client/client.py
1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 | |
fetch_member(user_id, guild_id) async ¶
Fetch a member from a guild.
Note
This method is an alias for the cache which will either return a cached object, or query discord for the object if its not already cached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id | Snowflake_Type | The ID of the member | required |
guild_id | Snowflake_Type | The ID of the guild to get the member from | required |
Returns:
| Type | Description |
|---|---|
Optional[Member] | Member object if found, otherwise None |
Source code in naff/client/client.py
2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 | |
get_member(user_id, guild_id) ¶
Get a member from a guild.
Note
This method is an alias for the cache which will return a cached object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id | Snowflake_Type | The ID of the member | required |
guild_id | Snowflake_Type | The ID of the guild to get the member from | required |
Returns:
| Type | Description |
|---|---|
Optional[Member] | Member object if found, otherwise None |
Source code in naff/client/client.py
2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 | |
fetch_scheduled_event(guild_id, scheduled_event_id, with_user_count=False) async ¶
Fetch a scheduled event by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild to get the scheduled event from | required |
scheduled_event_id | Snowflake_Type | The ID of the scheduled event to get | required |
with_user_count | bool | Whether to include the user count in the response | False |
Returns:
| Type | Description |
|---|---|
Optional[ScheduledEvent] | The scheduled event if found, otherwise None |
Source code in naff/client/client.py
2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 | |
fetch_custom_emoji(emoji_id, guild_id) async ¶
Fetch a custom emoji by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji_id | Snowflake_Type | The id of the custom emoji. | required |
guild_id | Snowflake_Type | The id of the guild the emoji belongs to. | required |
Returns:
| Type | Description |
|---|---|
Optional[CustomEmoji] | The custom emoji if found, otherwise None. |
Source code in naff/client/client.py
2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 | |
get_custom_emoji(emoji_id, guild_id=None) ¶
Get a custom emoji by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji_id | Snowflake_Type | The id of the custom emoji. | required |
guild_id | Optional[Snowflake_Type] | The id of the guild the emoji belongs to. | None |
Returns:
| Type | Description |
|---|---|
Optional[CustomEmoji] | The custom emoji if found, otherwise None. |
Source code in naff/client/client.py
2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 | |
fetch_sticker(sticker_id) async ¶
Fetch a sticker by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sticker_id | Snowflake_Type | The ID of the sticker. | required |
Returns:
| Type | Description |
|---|---|
Optional[Sticker] | A sticker object if found, otherwise None |
Source code in naff/client/client.py
2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 | |
fetch_nitro_packs() async ¶
List the sticker packs available to Nitro subscribers.
Returns:
| Type | Description |
|---|---|
Optional[List[StickerPack]] | A list of StickerPack objects if found, otherwise returns None |
Source code in naff/client/client.py
2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 | |
fetch_voice_regions() async ¶
List the voice regions available on Discord.
Returns:
| Type | Description |
|---|---|
List[VoiceRegion] | A list of voice regions. |
Source code in naff/client/client.py
2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 | |
connect_to_vc(guild_id, channel_id, muted=False, deafened=False) async ¶
Connect the bot to a voice channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id | Snowflake_Type | id of the guild the voice channel is in. | required |
channel_id | Snowflake_Type | id of the voice channel client wants to join. | required |
muted | bool | Whether the bot should be muted when connected. | False |
deafened | bool | Whether the bot should be deafened when connected. | False |
Returns:
| Type | Description |
|---|---|
ActiveVoiceState | The new active voice state on successfully connection. |
Source code in naff/client/client.py
2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 | |
get_bot_voice_state(guild_id) ¶
Get the bot's voice state for a guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id | Snowflake_Type | The target guild's id. | required |
Returns:
| Type | Description |
|---|---|
Optional[ActiveVoiceState] | The bot's voice state for the guild if connected, otherwise None. |
Source code in naff/client/client.py
2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 | |
change_presence(status=Status.ONLINE, activity=None) async ¶
Change the bots presence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status | Optional[Union[str, Status]] | The status for the bot to be. i.e. online, afk, etc. | Status.ONLINE |
activity | Optional[Union[Activity, str]] | The activity for the bot to be displayed as doing. | None |
Note
Bots may only be playing streaming listening watching or competing, other activity types are likely to fail.
Source code in naff/client/client.py
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 | |
AutoShardedClient ¶
Bases: Client
A client to automatically shard the bot.
You can optionally specify the total number of shards to start with, or it will be determined automatically.
Source code in naff/client/auto_shard_client.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
gateway_started() property ¶
Returns if the gateway has been started in all shards.
Source code in naff/client/auto_shard_client.py
47 48 49 50 | |
shards() property ¶
Returns a list of all shards currently in use.
Source code in naff/client/auto_shard_client.py
52 53 54 55 | |
latency() property ¶
The average latency of all active gateways.
Source code in naff/client/auto_shard_client.py
57 58 59 60 61 62 63 64 | |
latencies() property ¶
Return a dictionary of latencies for all shards.
Returns:
| Type | Description |
|---|---|
dict[int, float] | {shard_id: latency} |
Source code in naff/client/auto_shard_client.py
66 67 68 69 70 71 72 73 74 | |
stop() async ¶
Shutdown the bot.
Source code in naff/client/auto_shard_client.py
76 77 78 79 80 81 | |
get_guild_websocket(guild_id) ¶
Get the appropriate websocket for a given guild
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild | required |
Returns:
| Type | Description |
|---|---|
GatewayClient | A gateway client for the given ID |
Source code in naff/client/auto_shard_client.py
83 84 85 86 87 88 89 90 91 92 93 94 | |
get_shards_guild(shard_id) ¶
Returns the guilds that the specified shard can see
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shard_id | int | The ID of the shard | required |
Returns:
| Type | Description |
|---|---|
list[Guild] | A list of guilds |
Source code in naff/client/auto_shard_client.py
96 97 98 99 100 101 102 103 104 105 106 | |
get_shard_id(guild_id) ¶
Get the shard ID for a given guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild | required |
Returns:
| Type | Description |
|---|---|
int | The shard ID for the guild |
Source code in naff/client/auto_shard_client.py
108 109 110 111 112 113 114 115 116 117 118 | |
astart(token) async ¶
Asynchronous method to start the bot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token | str | Your bot's token | required |
Source code in naff/client/auto_shard_client.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
login(token) async ¶
Login to discord via http.
Note
You will need to run Naff.start_gateway() before you start receiving gateway events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token | str | Your bot's token | required |
Source code in naff/client/auto_shard_client.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
change_presence(status=Status.ONLINE, activity=None, *, shard_id=None) async ¶
Change the bot's presence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status | Optional[str | Status] | The status for the bot to be. i.e. online, afk, etc. | Status.ONLINE |
activity | Optional[str | Activity] | The activity for the bot to be displayed as doing. | None |
shard_id | int | None | The shard to change the presence on. If not specified, the presence will be changed on all shards. | None |
Note
Bots may only be playing streaming listening watching or competing, other activity types are likely to fail.
Source code in naff/client/auto_shard_client.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
ActiveVoiceState ¶
Bases: VoiceState
Source code in naff/models/naff/active_voice_state.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
ws: Optional[VoiceGateway] = field(default=None) class-attribute ¶
The websocket for this voice state
player: Optional[Player] = field(default=None) class-attribute ¶
The playback task that broadcasts audio data to discord
current_audio() property ¶
The current audio being played
Source code in naff/models/naff/active_voice_state.py
48 49 50 51 52 | |
volume() writable property ¶
Get the volume of the player
Source code in naff/models/naff/active_voice_state.py
54 55 56 57 | |
paused() property ¶
Is the player currently paused
Source code in naff/models/naff/active_voice_state.py
68 69 70 71 72 73 | |
playing() property ¶
Are we currently playing something?
Source code in naff/models/naff/active_voice_state.py
75 76 77 78 79 80 81 82 | |
stopped() property ¶
Is the player stopped?
Source code in naff/models/naff/active_voice_state.py
84 85 86 87 88 89 | |
connected() property ¶
Is this voice state currently connected?
Source code in naff/models/naff/active_voice_state.py
91 92 93 94 95 96 97 | |
wait_for_stopped() async ¶
Wait for the player to stop playing.
Source code in naff/models/naff/active_voice_state.py
103 104 105 106 107 | |
ws_connect() async ¶
Connect to the voice gateway for this voice state
Source code in naff/models/naff/active_voice_state.py
118 119 120 121 122 123 | |
connect(timeout=5) async ¶
Establish the voice connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout | int | How long to wait for state and server information from discord | 5 |
Raises:
| Type | Description |
|---|---|
VoiceAlreadyConnected | if the voice state is already connected to the voice channel |
VoiceConnectionTimeout | if the voice state fails to connect |
Source code in naff/models/naff/active_voice_state.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
disconnect() async ¶
Disconnect from the voice channel.
Source code in naff/models/naff/active_voice_state.py
157 158 159 | |
move(channel, timeout=5) async ¶
Move to another voice channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel | Snowflake_Type | The channel to move to | required |
timeout | int | How long to wait for state and server information from discord | 5 |
Source code in naff/models/naff/active_voice_state.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
stop() async ¶
Stop playback.
Source code in naff/models/naff/active_voice_state.py
189 190 191 192 | |
pause() ¶
Pause playback
Source code in naff/models/naff/active_voice_state.py
194 195 196 | |
resume() ¶
Resume playback.
Source code in naff/models/naff/active_voice_state.py
198 199 200 | |
play(audio) async ¶
Start playing an audio object.
Waits for the player to stop before returning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio | BaseAudio | The audio object to play | required |
Source code in naff/models/naff/active_voice_state.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
play_no_wait(audio) ¶
Start playing an audio object, but don't wait for playback to finish.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio | BaseAudio | The audio object to play | required |
Source code in naff/models/naff/active_voice_state.py
218 219 220 221 222 223 224 225 | |
User¶
BaseUser ¶
Bases: DiscordObject, _SendDMMixin
Base class for User, essentially partial user discord model.
Source code in naff/models/discord/user.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
tag() property ¶
Returns the user's Discord tag.
Source code in naff/models/discord/user.py
64 65 66 67 | |
mention() property ¶
Returns a string that would mention the user.
Source code in naff/models/discord/user.py
69 70 71 72 | |
display_name() property ¶
The users display name, will return nickname if one is set, otherwise will return username.
Source code in naff/models/discord/user.py
74 75 76 77 | |
display_avatar() property ¶
The users displayed avatar, will return guild_avatar if one is set, otherwise will return user avatar.
Source code in naff/models/discord/user.py
79 80 81 82 | |
fetch_dm() async ¶
Fetch the DM channel associated with this user.
Source code in naff/models/discord/user.py
84 85 86 | |
get_dm() ¶
Get the DM channel associated with this user.
Source code in naff/models/discord/user.py
88 89 90 | |
mutual_guilds() property ¶
Get a list of mutual guilds shared between this user and the client.
Note
This will only be accurate if the guild members are cached internally
Source code in naff/models/discord/user.py
92 93 94 95 96 97 98 99 100 101 102 | |
User ¶
Bases: BaseUser
Source code in naff/models/discord/user.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
member_instances() property ¶
Returns the member object for all guilds both the bot and the user are in.
Note
This will only be accurate if the guild members are cached internally
Source code in naff/models/discord/user.py
143 144 145 146 147 148 149 150 151 152 153 154 | |
NaffUser ¶
Bases: User
Source code in naff/models/discord/user.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
guilds() property ¶
The guilds the user is in.
Source code in naff/models/discord/user.py
180 181 182 183 | |
edit(username=MISSING, avatar=MISSING) async ¶
Edit the client's user.
You can either change the username, or avatar, or both at once. avatar may be set to None to remove your bot's avatar
Example Usage:
1 | |
1 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username | Absent[str] | The username you want to use | MISSING |
avatar | Absent[UPLOADABLE_TYPE] | The avatar to use. Can be a image file, path, or | MISSING |
Raises:
| Type | Description |
|---|---|
TooManyChanges | If you change the profile too many times |
Source code in naff/models/discord/user.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
Member ¶
Bases: DiscordObject, _SendDMMixin
Source code in naff/models/discord/user.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
user() property ¶
Returns this member's user object.
Source code in naff/models/discord/user.py
292 293 294 295 | |
nickname() writable property ¶
Alias for nick.
Source code in naff/models/discord/user.py
307 308 309 310 | |
guild() property ¶
The guild object this member is from.
Source code in naff/models/discord/user.py
317 318 319 320 | |
roles() property ¶
The roles this member has.
Source code in naff/models/discord/user.py
322 323 324 325 | |
top_role() property ¶
The member's top most role.
Source code in naff/models/discord/user.py
327 328 329 330 | |
display_name() property ¶
The users display name, will return nickname if one is set, otherwise will return username.
Source code in naff/models/discord/user.py
332 333 334 335 | |
display_avatar() property ¶
The users displayed avatar, will return guild_avatar if one is set, otherwise will return user avatar.
Source code in naff/models/discord/user.py
337 338 339 340 | |
premium() property ¶
Is this member a server booster?
Source code in naff/models/discord/user.py
342 343 344 345 | |
guild_permissions() property ¶
Returns the permissions this member has in the guild.
Returns:
| Type | Description |
|---|---|
Permissions | Permission data |
Source code in naff/models/discord/user.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
voice() property ¶
Returns the voice state of this user if any.
Source code in naff/models/discord/user.py
370 371 372 373 | |
has_permission(*permissions) ¶
Checks if the member has all the given permission(s).
Example Usage:
Two different styles can be used to call this method.
1 | |
1 | |
If member has both permissions, True gets returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*permissions | Permissions | The permission(s) to check whether the user has it. | () |
Source code in naff/models/discord/user.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
channel_permissions(channel) ¶
Returns the permissions this member has in a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel | TYPE_GUILD_CHANNEL | The channel in question | required |
Returns:
| Type | Description |
|---|---|
Permissions | Permissions data |
Note
This method is used in Channel.permissions_for
Source code in naff/models/discord/user.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
edit_nickname(new_nickname=MISSING, reason=MISSING) async ¶
Change the user's nickname.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_nickname | Absent[str] | The new nickname to apply | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Note
Leave new_nickname empty to clean user's nickname
Source code in naff/models/discord/user.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | |
add_role(role, reason=MISSING) async ¶
Add a role to this member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role | Union[Snowflake_Type, Role] | The role to add | required |
reason | Absent[str] | The reason for adding this role | MISSING |
Source code in naff/models/discord/user.py
462 463 464 465 466 467 468 469 470 471 472 473 | |
add_roles(roles, reason=MISSING) async ¶
Atomically add multiple roles to this member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roles | Iterable[Union[Snowflake_Type, Role]] | The roles to add | required |
reason | Absent[str] | The reason for adding the roles | MISSING |
Source code in naff/models/discord/user.py
475 476 477 478 479 480 481 482 483 484 485 | |
remove_role(role, reason=MISSING) async ¶
Remove a role from this user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role | Union[Snowflake_Type, Role] | The role to remove | required |
reason | Absent[str] | The reason for this removal | MISSING |
Source code in naff/models/discord/user.py
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
remove_roles(roles, reason=MISSING) async ¶
Atomically remove multiple roles from this member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roles | Iterable[Union[Snowflake_Type, Role]] | The roles to remove | required |
reason | Absent[str] | The reason for removing the roles | MISSING |
Source code in naff/models/discord/user.py
503 504 505 506 507 508 509 510 511 512 513 | |
has_role(*roles) ¶
Checks if the user has the given role(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*roles | Union[Snowflake_Type, Role] | The role(s) to check whether the user has it. | () |
Source code in naff/models/discord/user.py
515 516 517 518 519 520 521 522 523 | |
timeout(communication_disabled_until, reason=MISSING) async ¶
Disable a members communication for a given time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
communication_disabled_until | Union[Timestamp, datetime, int, float, str, None] | The time until the user can communicate again | required |
reason | Absent[str] | The reason for this timeout | MISSING |
Source code in naff/models/discord/user.py
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | |
move(channel_id) async ¶
Moves the member to a different voice channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id | Snowflake_Type | The voice channel to move the member to | required |
Source code in naff/models/discord/user.py
550 551 552 553 554 555 556 557 558 | |
edit(*, nickname=MISSING, roles=MISSING, mute=MISSING, deaf=MISSING, channel_id=MISSING, communication_disabled_until=MISSING, reason=MISSING) async ¶
Modify attrbutes of this guild member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nickname | Absent[str] | Value to set users nickname to | MISSING |
roles | Absent[Iterable[Snowflake_Type]] | Array of role ids the member is assigned | MISSING |
mute | Absent[bool] | Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel | MISSING |
deaf | Absent[bool] | Whether the user is deafened in voice channels | MISSING |
channel_id | Absent[Snowflake_Type] | id of channel to move user to (if they are connected to voice) | MISSING |
communication_disabled_until | Absent[Union[Timestamp, None]] | when the user's timeout will expire and the user will be able to communicate in the guild again | MISSING |
reason | Absent[str] | An optional reason for the audit log | MISSING |
Source code in naff/models/discord/user.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | |
kick(reason=MISSING) async ¶
Remove a member from the guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason | Absent[str] | The reason for this removal | MISSING |
Source code in naff/models/discord/user.py
595 596 597 598 599 600 601 602 603 | |
ban(delete_message_days=MISSING, delete_message_seconds=0, reason=MISSING) async ¶
Ban a member from the guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delete_message_days | int | (deprecated) The number of days of messages to delete | MISSING |
delete_message_seconds | int | The number of seconds of messages to delete | 0 |
reason | Absent[str] | The reason for this ban | MISSING |
Source code in naff/models/discord/user.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
VoiceState ¶
Bases: ClientObject
Source code in naff/models/discord/voice_state.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
user_id: Snowflake_Type = field(default=MISSING, converter=to_snowflake) class-attribute ¶
the user id this voice state is for
session_id: str = field(default=MISSING) class-attribute ¶
the session id for this voice state
deaf: bool = field(default=False) class-attribute ¶
whether this user is deafened by the server
mute: bool = field(default=False) class-attribute ¶
whether this user is muted by the server
self_deaf: bool = field(default=False) class-attribute ¶
whether this user is locally deafened
self_mute: bool = field(default=False) class-attribute ¶
whether this user is locally muted
self_stream: Optional[bool] = field(default=False) class-attribute ¶
whether this user is streaming using "Go Live"
self_video: bool = field(default=False) class-attribute ¶
whether this user's camera is enabled
suppress: bool = field(default=False) class-attribute ¶
whether this user is muted by the current user
request_to_speak_timestamp: Optional[Timestamp] = field(default=None, converter=optional_c(timestamp_converter)) class-attribute ¶
the time at which the user requested to speak
guild() property ¶
The guild this voice state is for.
Source code in naff/models/discord/voice_state.py
50 51 52 53 | |
channel() property ¶
The channel the user is connected to.
Source code in naff/models/discord/voice_state.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
member() property ¶
The member this voice state is for.
Source code in naff/models/discord/voice_state.py
79 80 81 82 | |
VoiceRegion ¶
Bases: DictSerializationMixin
A voice region.
Source code in naff/models/discord/voice_state.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
id: str = field(repr=True) class-attribute ¶
unique ID for the region
name: str = field(repr=True) class-attribute ¶
name of the region
vip: bool = field(default=False, repr=True) class-attribute ¶
whether this is a VIP-only voice region
optimal: bool = field(default=False) class-attribute ¶
true for a single server that is closest to the current user's client
deprecated: bool = field(default=False) class-attribute ¶
whether this is a deprecated voice region (avoid switching to these)
custom: bool = field(default=False) class-attribute ¶
whether this is a custom voice region (used for events/etc)
Guild¶
GuildBan ¶
BaseGuild ¶
Bases: DiscordObject
Source code in naff/models/discord/guild.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
name: str = field(repr=True) class-attribute ¶
Name of guild. (2-100 characters, excluding trailing and leading whitespace)
description: Optional[str] = field(repr=True, default=None) class-attribute ¶
The description for the guild, if the guild is discoverable
icon: Optional[models.Asset] = field(default=None) class-attribute ¶
Icon image asset
splash: Optional[models.Asset] = field(default=None) class-attribute ¶
Splash image asset
discovery_splash: Optional[models.Asset] = field(default=None) class-attribute ¶
Discovery splash image. Only present for guilds with the "DISCOVERABLE" feature.
features: List[str] = field(factory=list) class-attribute ¶
The features of this guild
GuildPreview ¶
Bases: BaseGuild
A partial guild object.
Source code in naff/models/discord/guild.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
emoji: list[models.PartialEmoji] = field(factory=list) class-attribute ¶
A list of custom emoji from this guild
approximate_member_count: int = field(default=0) class-attribute ¶
Approximate number of members in this guild
approximate_presence_count: int = field(default=0) class-attribute ¶
Approximate number of online members in this guild
Guild ¶
Bases: BaseGuild
Guilds in Discord represent an isolated collection of users and channels, and are often referred to as "servers" in the UI.
Source code in naff/models/discord/guild.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 | |
unavailable: bool = field(default=False) class-attribute ¶
True if this guild is unavailable due to an outage.
afk_channel_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
The channel id for afk.
afk_timeout: Optional[int] = field(default=None) class-attribute ¶
afk timeout in seconds.
widget_enabled: bool = field(default=False) class-attribute ¶
True if the server widget is enabled.
widget_channel_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
The channel id that the widget will generate an invite to, or None if set to no invite.
verification_level: Union[VerificationLevels, int] = field(default=VerificationLevels.NONE) class-attribute ¶
The verification level required for the guild.
default_message_notifications: Union[DefaultNotificationLevels, int] = field(default=DefaultNotificationLevels.ALL_MESSAGES) class-attribute ¶
The default message notifications level.
explicit_content_filter: Union[ExplicitContentFilterLevels, int] = field(default=ExplicitContentFilterLevels.DISABLED) class-attribute ¶
The explicit content filter level.
mfa_level: Union[MFALevels, int] = field(default=MFALevels.NONE) class-attribute ¶
The required MFA (Multi Factor Authentication) level for the guild.
system_channel_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
The id of the channel where guild notices such as welcome messages and boost events are posted.
system_channel_flags: SystemChannelFlags = field(default=SystemChannelFlags.NONE, converter=SystemChannelFlags) class-attribute ¶
The system channel flags.
rules_channel_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
The id of the channel where Community guilds can display rules and/or guidelines.
joined_at: str = field(default=None, converter=optional(timestamp_converter)) class-attribute ¶
When this guild was joined at.
large: bool = field(default=False) class-attribute ¶
True if this is considered a large guild.
member_count: int = field(default=0) class-attribute ¶
The total number of members in this guild.
presences: List[dict] = field(factory=list) class-attribute ¶
The presences of the members in the guild, will only include non-offline members if the size is greater than large threshold.
max_presences: Optional[int] = field(default=None) class-attribute ¶
The maximum number of presences for the guild. (None is always returned, apart from the largest of guilds)
max_members: Optional[int] = field(default=None) class-attribute ¶
The maximum number of members for the guild.
vanity_url_code: Optional[str] = field(default=None) class-attribute ¶
The vanity url code for the guild.
banner: Optional[str] = field(default=None) class-attribute ¶
Hash for banner image.
premium_tier: Optional[str] = field(default=None) class-attribute ¶
The premium tier level. (Server Boost level)
premium_subscription_count: int = field(default=0) class-attribute ¶
The number of boosts this guild currently has.
preferred_locale: str = field() class-attribute ¶
The preferred locale of a Community guild. Used in server discovery and notices from Discord. Defaults to "en-US"
public_updates_channel_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
The id of the channel where admins and moderators of Community guilds receive notices from Discord.
max_video_channel_users: int = field(default=0) class-attribute ¶
The maximum amount of users in a video channel.
welcome_screen: Optional[GuildWelcome] = field(default=None) class-attribute ¶
The welcome screen of a Community guild, shown to new members, returned in an Invite's guild object.
nsfw_level: Union[NSFWLevels, int] = field(default=NSFWLevels.DEFAULT) class-attribute ¶
The guild NSFW level.
stage_instances: List[dict] = field(factory=list) class-attribute ¶
Stage instances in the guild.
chunked = field(factory=asyncio.Event, metadata=no_export_meta) class-attribute ¶
An event that is fired when this guild has been chunked
create(name, client, *, icon=MISSING, verification_level=MISSING, default_message_notifications=MISSING, explicit_content_filter=MISSING, roles=MISSING, channels=MISSING, afk_channel_id=MISSING, afk_timeout=MISSING, system_channel_id=MISSING, system_channel_flags=MISSING) async classmethod ¶
Create a guild.
Note
This method will only work for bots in less than 10 guilds.
Param notes
Roles: - When using the roles parameter, the first member of the array is used to change properties of the guild's @everyone role. If you are trying to bootstrap a guild with additional roles, keep this in mind. - When using the roles parameter, the required id field within each role object is an integer placeholder, and will be replaced by the API upon consumption. Its purpose is to allow you to overwrite a role's permissions in a channel when also passing in channels with the channels array.
Channels: - When using the channels parameter, the position field is ignored, and none of the default channels are created. - When using the channels parameter, the id field within each channel object may be set to an integer placeholder, and will be replaced by the API upon consumption. Its purpose is to allow you to create GUILD_CATEGORY channels by setting the parent_id field on any children to the category's id field. Category channels must be listed before any children.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | name of the guild (2-100 characters) | required |
client | Client | The NAFF client | required |
icon | Absent[Optional[UPLOADABLE_TYPE]] | An icon for the guild | MISSING |
verification_level | Absent[VerificationLevels] | The guild's verification level | MISSING |
default_message_notifications | Absent[DefaultNotificationLevels] | The default message notification level | MISSING |
explicit_content_filter | Absent[ExplicitContentFilterLevels] | The guild's explicit content filter level | MISSING |
roles | Absent[list[dict]] | An array of partial role dictionaries | MISSING |
channels | Absent[list[dict]] | An array of partial channel dictionaries | MISSING |
afk_channel_id | Absent[Snowflake_Type] | id for afk channel | MISSING |
afk_timeout | Absent[int] | afk timeout in seconds | MISSING |
system_channel_id | Absent[Snowflake_Type] | the id of the channel where guild notices should go | MISSING |
system_channel_flags | Absent[SystemChannelFlags] | flags for the system channel | MISSING |
Returns:
| Type | Description |
|---|---|
Guild | The created guild object |
Source code in naff/models/discord/guild.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
channels() property ¶
Returns a list of channels associated with this guild.
Source code in naff/models/discord/guild.py
314 315 316 317 | |
threads() property ¶
Returns a list of threads associated with this guild.
Source code in naff/models/discord/guild.py
319 320 321 322 | |
members() property ¶
Returns a list of all members within this guild.
Source code in naff/models/discord/guild.py
324 325 326 327 | |
premium_subscribers() property ¶
Returns a list of all premium subscribers
Source code in naff/models/discord/guild.py
329 330 331 332 | |
bots() property ¶
Returns a list of all bots within this guild
Source code in naff/models/discord/guild.py
334 335 336 337 | |
humans() property ¶
Returns a list of all humans within this guild
Source code in naff/models/discord/guild.py
339 340 341 342 | |
roles() property ¶
Returns a list of roles associated with this guild.
Source code in naff/models/discord/guild.py
344 345 346 347 | |
me() property ¶
Returns this bots member object within this guild.
Source code in naff/models/discord/guild.py
349 350 351 352 | |
system_channel() property ¶
Returns the channel this guild uses for system messages.
Source code in naff/models/discord/guild.py
354 355 356 357 | |
rules_channel() property ¶
Returns the channel declared as a rules channel.
Source code in naff/models/discord/guild.py
359 360 361 362 | |
public_updates_channel() property ¶
Returns the channel where server staff receive notices from Discord.
Source code in naff/models/discord/guild.py
364 365 366 367 | |
emoji_limit() property ¶
The maximum number of emoji this guild can have.
Source code in naff/models/discord/guild.py
369 370 371 372 373 | |
sticker_limit() property ¶
The maximum number of stickers this guild can have.
Source code in naff/models/discord/guild.py
375 376 377 378 379 | |
bitrate_limit() property ¶
The maximum bitrate for this guild.
Source code in naff/models/discord/guild.py
381 382 383 384 385 | |
filesize_limit() property ¶
The maximum filesize that may be uploaded within this guild.
Source code in naff/models/discord/guild.py
387 388 389 390 | |
default_role() property ¶
The @everyone role in this guild.
Source code in naff/models/discord/guild.py
392 393 394 395 | |
premium_subscriber_role() property ¶
The role given to boosters of this server, if set.
Source code in naff/models/discord/guild.py
397 398 399 400 401 402 403 | |
my_role() property ¶
The role associated with this client, if set.
Source code in naff/models/discord/guild.py
405 406 407 408 409 410 411 412 | |
permissions() property ¶
Alias for me.guild_permissions
Source code in naff/models/discord/guild.py
414 415 416 417 | |
voice_state() property ¶
Get the bot's voice state for the guild.
Source code in naff/models/discord/guild.py
419 420 421 422 | |
voice_states() property ¶
Get a list of the active voice states in this guild.
Source code in naff/models/discord/guild.py
424 425 426 427 428 429 430 | |
fetch_member(member_id) async ¶
Return the Member with the given discord ID, fetching from the API if necessary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member_id | Snowflake_Type | The ID of the member. | required |
Returns:
| Type | Description |
|---|---|
Optional[Member] | The member object fetched. If the member is not in this guild, returns None. |
Source code in naff/models/discord/guild.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
get_member(member_id) ¶
Return the Member with the given discord ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member_id | Snowflake_Type | The ID of the member | required |
Returns:
| Type | Description |
|---|---|
Optional[Member] | Member object or None |
Source code in naff/models/discord/guild.py
448 449 450 451 452 453 454 455 456 457 458 459 | |
fetch_owner() async ¶
Return the Guild owner, fetching from the API if necessary.
Returns:
| Type | Description |
|---|---|
Member | Member object or None |
Source code in naff/models/discord/guild.py
461 462 463 464 465 466 467 468 469 | |
get_owner() ¶
Return the Guild owner
Returns:
| Type | Description |
|---|---|
Member | Member object or None |
Source code in naff/models/discord/guild.py
471 472 473 474 475 476 477 478 479 | |
fetch_channels() async ¶
Fetch this guild's channels.
Returns:
| Type | Description |
|---|---|
List[TYPE_VOICE_CHANNEL] | A list of channels in this guild |
Source code in naff/models/discord/guild.py
481 482 483 484 485 486 487 488 489 490 | |
is_owner(user) ¶
Whether the user is owner of the guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user | Snowflake_Type | The user to check | required |
Returns:
| Type | Description |
|---|---|
bool | True if the user is the owner of the guild, False otherwise. |
Note
the user argument can be any type that meets Snowflake_Type
Source code in naff/models/discord/guild.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | |
edit_nickname(new_nickname=MISSING, reason=MISSING) async ¶
Alias for me.edit_nickname
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_nickname | Absent[str] | The new nickname to apply | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Note
Leave new_nickname empty to clean user's nickname
Source code in naff/models/discord/guild.py
508 509 510 511 512 513 514 515 516 517 518 519 520 | |
http_chunk() async ¶
Populates all members of this guild using the REST API.
Source code in naff/models/discord/guild.py
522 523 524 525 526 527 528 529 530 531 532 533 | |
gateway_chunk(wait=True, presences=True) async ¶
Trigger a gateway get_members event, populating this object with members.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wait | Wait for chunking to be completed before continuing | True | |
presences | Do you need presence data for members? | True |
Source code in naff/models/discord/guild.py
535 536 537 538 539 540 541 542 543 544 545 546 | |
chunk() async ¶
Populates all members of this guild using the REST API.
Source code in naff/models/discord/guild.py
548 549 550 | |
chunk_guild(wait=True, presences=True) async ¶
Trigger a gateway get_members event, populating this object with members.
Depreciation Warning
Gateway chunking is deprecated and replaced by http chunking. Use guild.gateway_chunk if you need gateway chunking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wait | Wait for chunking to be completed before continuing | True | |
presences | Do you need presence data for members? | True |
Source code in naff/models/discord/guild.py
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
process_member_chunk(chunk) async ¶
Receive and either cache or process the chunks of members from gateway.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk | dict | A member chunk from discord | required |
Source code in naff/models/discord/guild.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | |
fetch_audit_log(user_id=MISSING, action_type=MISSING, before=MISSING, after=MISSING, limit=100) async ¶
Fetch section of the audit log for this guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id | Optional[Snowflake_Type] | The ID of the user to filter by | MISSING |
action_type | Optional[AuditLogEventType] | The type of action to filter by | MISSING |
before | Optional[Snowflake_Type] | The ID of the entry to start at | MISSING |
after | Optional[Snowflake_Type] | The ID of the entry to end at | MISSING |
limit | int | The number of entries to return | 100 |
Returns:
| Type | Description |
|---|---|
AuditLog | An AuditLog object |
Source code in naff/models/discord/guild.py
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | |
audit_log_history(user_id=MISSING, action_type=MISSING, before=MISSING, after=MISSING, limit=100) ¶
Get an async iterator for the history of the audit log.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id | MISSING | ||
action_type | MISSING | ||
before | Optional[Snowflake_Type] | get entries before this message ID | MISSING |
after | Optional[Snowflake_Type] | get entries after this message ID | MISSING |
limit | int | The maximum number of entries to return (set to 0 for no limit) | 100 |
Example Usage:
1 2 3 4 | |
1 2 3 | |
Returns:
| Type | Description |
|---|---|
AuditLogHistory | AuditLogHistory (AsyncIterator) |
Source code in naff/models/discord/guild.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | |
edit(name=MISSING, description=MISSING, verification_level=MISSING, default_message_notifications=MISSING, explicit_content_filter=MISSING, afk_channel=MISSING, afk_timeout=MISSING, system_channel=MISSING, system_channel_flags=MISSING, owner=MISSING, icon=MISSING, splash=MISSING, discovery_splash=MISSING, banner=MISSING, rules_channel=MISSING, public_updates_channel=MISSING, preferred_locale=MISSING, features=MISSING, reason=MISSING) async ¶
Edit the guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[Optional[str]] | The new name of the guild. | MISSING |
description | Absent[Optional[str]] | The new description of the guild. | MISSING |
verification_level | Absent[Optional[VerificationLevels]] | The new verification level for the guild. | MISSING |
default_message_notifications | Absent[Optional[DefaultNotificationLevels]] | The new notification level for the guild. | MISSING |
explicit_content_filter | Absent[Optional[ExplicitContentFilterLevels]] | The new explicit content filter level for the guild. | MISSING |
afk_channel | Absent[Optional[Union[GuildVoice, Snowflake_Type]]] | The voice channel that should be the new AFK channel. | MISSING |
afk_timeout | Absent[Optional[int]] | How many seconds does a member need to be afk before they get moved to the AFK channel. Must be either | MISSING |
icon | Absent[Optional[UPLOADABLE_TYPE]] | The new icon. Requires a bytes like object or a path to an image. | MISSING |
owner | Absent[Optional[Union[Member, Snowflake_Type]]] | The new owner of the guild. You, the bot, need to be owner for this to work. | MISSING |
splash | Absent[Optional[UPLOADABLE_TYPE]] | The new invite splash image. Requires a bytes like object or a path to an image. | MISSING |
discovery_splash | Absent[Optional[UPLOADABLE_TYPE]] | The new discovery image. Requires a bytes like object or a path to an image. | MISSING |
banner | Absent[Optional[UPLOADABLE_TYPE]] | The new banner image. Requires a bytes like object or a path to an image. | MISSING |
system_channel | Absent[Optional[Union[GuildText, Snowflake_Type]]] | The text channel where new system messages should appear. This includes boosts and welcome messages. | MISSING |
system_channel_flags | Absent[Union[SystemChannelFlags, int]] | The new settings for the system channel. | MISSING |
rules_channel | Absent[Optional[Union[GuildText, Snowflake_Type]]] | The text channel where your rules and community guidelines are displayed. | MISSING |
public_updates_channel | Absent[Optional[Union[GuildText, Snowflake_Type]]] | The text channel where updates from discord should appear. | MISSING |
preferred_locale | Absent[Optional[str]] | The new preferred locale of the guild. Must be an ISO 639 code. | MISSING |
features | Absent[Optional[list[str]]] | The enabled guild features | MISSING |
reason | Absent[Optional[str]] | An optional reason for the audit log. | MISSING |
Source code in naff/models/discord/guild.py
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 | |
create_custom_emoji(name, imagefile, roles=MISSING, reason=MISSING) async ¶
Create a new custom emoji for the guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | Name of the emoji | required |
imagefile | UPLOADABLE_TYPE | The emoji image. (Supports PNG, JPEG, WebP, GIF) | required |
roles | Absent[List[Union[Snowflake_Type, Role]]] | Roles allowed to use this emoji. | MISSING |
reason | Absent[Optional[str]] | An optional reason for the audit log. | MISSING |
Returns:
| Type | Description |
|---|---|
CustomEmoji | The new custom emoji created. |
Source code in naff/models/discord/guild.py
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | |
create_guild_template(name, description=MISSING) async ¶
Create a new guild template based on this guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the template (1-100 characters) | required |
description | Absent[str] | The description for the template (0-120 characters) | MISSING |
Returns:
| Type | Description |
|---|---|
GuildTemplate | The new guild template created. |
Source code in naff/models/discord/guild.py
786 787 788 789 790 791 792 793 794 795 796 797 798 799 | |
fetch_guild_templates() async ¶
Fetch all guild templates for this guild.
Returns:
| Type | Description |
|---|---|
List[GuildTemplate] | A list of guild template objects. |
Source code in naff/models/discord/guild.py
801 802 803 804 805 806 807 808 809 810 | |
fetch_all_custom_emojis() async ¶
Gets all the custom emoji present for this guild.
Returns:
| Type | Description |
|---|---|
List[CustomEmoji] | A list of custom emoji objects. |
Source code in naff/models/discord/guild.py
812 813 814 815 816 817 818 819 820 821 | |
fetch_custom_emoji(emoji_id) async ¶
Fetches the custom emoji present for this guild, based on the emoji id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji_id | Snowflake_Type | The target emoji to get data of. | required |
Returns:
| Type | Description |
|---|---|
Optional[CustomEmoji] | The custom emoji object. If the emoji is not found, returns None. |
Source code in naff/models/discord/guild.py
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | |
get_custom_emoji(emoji_id) ¶
Gets the custom emoji present for this guild, based on the emoji id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji_id | Snowflake_Type | The target emoji to get data of. | required |
Returns:
| Type | Description |
|---|---|
Optional[CustomEmoji] | The custom emoji object. |
Source code in naff/models/discord/guild.py
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 | |
create_channel(channel_type, name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, bitrate=64000, user_limit=0, rate_limit_per_user=0, reason=MISSING) async ¶
Create a guild channel, allows for explicit channel type setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_type | Union[ChannelTypes, int] | The type of channel to create | required |
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this channel should be within | None |
nsfw | bool | Should this channel be marked nsfw | False |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
TYPE_GUILD_CHANNEL | The newly created channel. |
Source code in naff/models/discord/guild.py
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 | |
create_text_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, rate_limit_per_user=0, reason=MISSING) async ¶
Create a text channel in this guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this channel should be within | None |
nsfw | bool | Should this channel be marked nsfw | False |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildText | The newly created text channel. |
Source code in naff/models/discord/guild.py
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 | |
create_forum_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, rate_limit_per_user=0, reason=MISSING) async ¶
Create a forum channel in this guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the forum channel | required |
topic | Absent[Optional[str]] | The topic of the forum channel | MISSING |
position | Absent[Optional[int]] | The position of the forum channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the forum channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this forum channel should be within | None |
nsfw | bool | Should this forum be marked nsfw | False |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildForum | The newly created forum channel. |
Source code in naff/models/discord/guild.py
950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 | |
create_news_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, reason=MISSING) async ¶
Create a news channel in this guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this channel should be within | None |
nsfw | bool | Should this channel be marked nsfw | False |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildNews | The newly created news channel. |
Source code in naff/models/discord/guild.py
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 | |
create_voice_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, bitrate=64000, user_limit=0, reason=MISSING) async ¶
Create a guild voice channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this channel should be within | None |
nsfw | bool | Should this channel be marked nsfw | False |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildVoice | The newly created voice channel. |
Source code in naff/models/discord/guild.py
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 | |
create_stage_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=MISSING, bitrate=64000, user_limit=0, reason=MISSING) async ¶
Create a guild stage channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Absent[Union[Snowflake_Type, GuildCategory]] | The category this channel should be within | MISSING |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildStageVoice | The newly created stage channel. |
Source code in naff/models/discord/guild.py
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 | |
create_category(name, position=MISSING, permission_overwrites=MISSING, reason=MISSING) async ¶
Create a category within this guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the channel | required |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildCategory | The newly created category. |
Source code in naff/models/discord/guild.py
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 | |
delete_channel(channel, reason=None) async ¶
Delete the given channel, can handle either a snowflake or channel object.
This is effectively just an alias for channel.delete()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel | Union[TYPE_GUILD_CHANNEL, Snowflake_Type] | The channel to be deleted | required |
reason | str | The reason for this deletion | None |
Source code in naff/models/discord/guild.py
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 | |
list_scheduled_events(with_user_count=False) async ¶
List all scheduled events in this guild.
Returns:
| Type | Description |
|---|---|
List[ScheduledEvent] | A list of scheduled events. |
Source code in naff/models/discord/guild.py
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 | |
fetch_scheduled_event(scheduled_event_id, with_user_count=False) async ¶
Get a scheduled event by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheduled_event_id | Snowflake_Type | The id of the scheduled event. | required |
with_user_count | bool | Whether to include the user count in the response. | False |
Returns:
| Type | Description |
|---|---|
Optional[ScheduledEvent] | The scheduled event. If the event does not exist, returns None. |
Source code in naff/models/discord/guild.py
1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 | |
create_scheduled_event(name, event_type, start_time, end_time=MISSING, description=MISSING, channel_id=MISSING, external_location=MISSING, entity_metadata=None, privacy_level=ScheduledEventPrivacyLevel.GUILD_ONLY, cover_image=MISSING, reason=MISSING) async ¶
Create a scheduled guild event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | event name | required |
event_type | ScheduledEventType | event type | required |
start_time | Timestamp |
| required |
end_time | Absent[Optional[Timestamp]] |
| MISSING |
description | Absent[Optional[str]] | event description | MISSING |
channel_id | Absent[Optional[Snowflake_Type]] | channel id | MISSING |
external_location | Absent[Optional[str]] | event external location (For external events) | MISSING |
entity_metadata | Optional[dict] | event metadata (additional data for the event) | None |
privacy_level | ScheduledEventPrivacyLevel | event privacy level | ScheduledEventPrivacyLevel.GUILD_ONLY |
cover_image | Absent[UPLOADABLE_TYPE] | the cover image of the scheduled event | MISSING |
reason | Absent[Optional[str]] | reason for creating this scheduled event | MISSING |
Returns:
| Type | Description |
|---|---|
ScheduledEvent | The newly created ScheduledEvent object |
Note
For external events, external_location is required For voice/stage events, channel_id is required
Note
entity_metadata is the backend dictionary for fluff fields. Where possible, we plan to expose these fields directly. The full list of supported fields is https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-metadata Example: entity_metadata=dict(location="cool place")
Source code in naff/models/discord/guild.py
1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 | |
create_custom_sticker(name, imagefile, description=MISSING, tags=MISSING, reason=MISSING) async ¶
Creates a custom sticker for a guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the sticker (2-30 characters) | required |
imagefile | UPLOADABLE_TYPE | The sticker file to upload, must be a PNG, APNG, or Lottie JSON file (max 500 KB) | required |
description | Absent[Optional[str]] | The description of the sticker (empty or 2-100 characters) | MISSING |
tags | Absent[Optional[str]] | Autocomplete/suggestion tags for the sticker (max 200 characters) | MISSING |
reason | Absent[Optional[str]] | Reason for creating the sticker | MISSING |
Returns:
| Type | Description |
|---|---|
Sticker | New Sticker instance |
Source code in naff/models/discord/guild.py
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 | |
fetch_all_custom_stickers() async ¶
Fetches all custom stickers for a guild.
Returns:
| Type | Description |
|---|---|
List[Sticker] | List of Sticker objects |
Source code in naff/models/discord/guild.py
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 | |
fetch_custom_sticker(sticker_id) async ¶
Fetches a specific custom sticker for a guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sticker_id | Snowflake_Type | ID of sticker to get | required |
Returns:
| Type | Description |
|---|---|
Optional[Sticker] | The custom sticker object. If the sticker does not exist, returns None. |
Source code in naff/models/discord/guild.py
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 | |
fetch_active_threads() async ¶
Fetches all active threads in the guild, including public and private threads. Threads are ordered by their id, in descending order.
Returns:
| Type | Description |
|---|---|
ThreadList | List of active threads and thread member object for each returned thread the bot user has joined. |
Source code in naff/models/discord/guild.py
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 | |
fetch_role(role_id) async ¶
Fetch the specified role by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role_id | Snowflake_Type | The ID of the role to get | required |
Returns:
| Type | Description |
|---|---|
Optional[Role] | The role object. If the role does not exist, returns None. |
Source code in naff/models/discord/guild.py
1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 | |
get_role(role_id) ¶
Get the specified role by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role_id | Snowflake_Type | The ID of the role to get | required |
Returns:
| Type | Description |
|---|---|
Optional[Role] | A role object or None if the role is not found. |
Source code in naff/models/discord/guild.py
1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 | |
create_role(name=MISSING, permissions=MISSING, colour=MISSING, color=MISSING, hoist=False, mentionable=False, icon=MISSING, reason=MISSING) async ¶
Create a new role for the guild. You must have the manage roles permission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[Optional[str]] | The name the role should have. | MISSING |
permissions | Absent[Optional[Permissions]] | The permissions the role should have. | MISSING |
colour | Absent[Optional[Union[Color, int]]] | The colour of the role. Can be either | MISSING |
color | Absent[Optional[Union[Color, int]]] | Alias for | MISSING |
icon | Absent[Optional[UPLOADABLE_TYPE]] | Can be either a bytes like object or a path to an image, or a unicode emoji which is supported by discord. | MISSING |
hoist | Optional[bool] | Whether the role is shown separately in the members list. | False |
mentionable | Optional[bool] | Whether the role can be mentioned. | False |
reason | Absent[Optional[str]] | An optional reason for the audit log. | MISSING |
Returns:
| Type | Description |
|---|---|
Role | A role object or None if the role is not found. |
Source code in naff/models/discord/guild.py
1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 | |
get_channel(channel_id) ¶
Returns a channel with the given channel_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get | required |
Returns:
| Type | Description |
|---|---|
Optional[TYPE_GUILD_CHANNEL] | Channel object if found, otherwise None |
Source code in naff/models/discord/guild.py
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 | |
fetch_channel(channel_id) async ¶
Returns a channel with the given channel_id from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get | required |
Returns:
| Type | Description |
|---|---|
Optional[TYPE_GUILD_CHANNEL] | The channel object. If the channel does not exist, returns None. |
Source code in naff/models/discord/guild.py
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 | |
get_thread(thread_id) ¶
Returns a Thread with the given thread_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thread_id | Snowflake_Type | The ID of the thread to get | required |
Returns:
| Type | Description |
|---|---|
Optional[TYPE_THREAD_CHANNEL] | Thread object if found, otherwise None |
Source code in naff/models/discord/guild.py
1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 | |
fetch_thread(thread_id) async ¶
Returns a Thread with the given thread_id from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thread_id | Snowflake_Type | The ID of the thread to get | required |
Returns:
| Type | Description |
|---|---|
Optional[TYPE_THREAD_CHANNEL] | Thread object if found, otherwise None |
Source code in naff/models/discord/guild.py
1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 | |
prune_members(days=7, roles=None, compute_prune_count=True, reason=MISSING) async ¶
Begin a guild prune. Removes members from the guild who who have not interacted for the last days days. By default, members with roles are excluded from pruning, to include them, pass their role (or role id) in roles Requires kick members permission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days | int | number of days to prune (1-30) | 7 |
roles | Optional[List[Snowflake_Type]] | list of roles to include in the prune | None |
compute_prune_count | bool | Whether the number of members pruned should be calculated (disable this for large guilds) | True |
reason | Absent[str] | The reason for this prune | MISSING |
Returns:
| Type | Description |
|---|---|
Optional[int] | The total number of members pruned, if |
Source code in naff/models/discord/guild.py
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 | |
estimate_prune_members(days=7, roles=MISSING) async ¶
Calculate how many members would be pruned, should guild.prune_members be used. By default, members with roles are excluded from pruning, to include them, pass their role (or role id) in roles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days | int | number of days to prune (1-30) | 7 |
roles | List[Union[Snowflake_Type, Role]] | list of roles to include in the prune | MISSING |
Returns:
| Type | Description |
|---|---|
int | Total number of members that would be pruned |
Source code in naff/models/discord/guild.py
1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | |
leave() async ¶
Leave this guild.
Source code in naff/models/discord/guild.py
1564 1565 1566 | |
delete() async ¶
Delete the guild.
Note
You must own this guild to do this.
Source code in naff/models/discord/guild.py
1568 1569 1570 1571 1572 1573 1574 1575 1576 | |
kick(user, reason=MISSING) async ¶
Kick a user from the guild.
Note
You must have the kick members permission
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user | Union[User, Member, Snowflake_Type] | The user to kick | required |
reason | Absent[str] | The reason for the kick | MISSING |
Source code in naff/models/discord/guild.py
1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 | |
ban(user, delete_message_days=MISSING, delete_message_seconds=0, reason=MISSING) async ¶
Ban a user from the guild.
Note
You must have the ban members permission
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user | Union[User, Member, Snowflake_Type] | The user to ban | required |
delete_message_days | Absent[int] | (deprecated) How many days worth of messages to remove | MISSING |
delete_message_seconds | int | How many seconds worth of messages to remove | 0 |
reason | Absent[str] | The reason for the ban | MISSING |
Source code in naff/models/discord/guild.py
1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 | |
fetch_ban(user) async ¶
Fetches the ban information for the specified user in the guild. You must have the ban members permission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user | Union[User, Member, Snowflake_Type] | The user to look up. | required |
Returns:
| Type | Description |
|---|---|
Optional[GuildBan] | The ban information. If the user is not banned, returns None. |
Source code in naff/models/discord/guild.py
1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 | |
fetch_bans(before=MISSING, after=MISSING, limit=1000) async ¶
Fetches bans for the guild. You must have the ban members permission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
before | Optional[Snowflake_Type] | consider only users before given user id | MISSING |
after | Optional[Snowflake_Type] | consider only users after given user id | MISSING |
limit | int | number of users to return (up to maximum 1000) | 1000 |
Returns:
| Type | Description |
|---|---|
list[GuildBan] | A list containing bans and information about them. |
Source code in naff/models/discord/guild.py
1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 | |
create_auto_moderation_rule(name, *, trigger, actions, exempt_roles=MISSING, exempt_channels=MISSING, enabled=True, event_type=AutoModEvent.MESSAGE_SEND) async ¶
Create an auto-moderation rule in this guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the rule | required |
trigger | BaseTrigger | The trigger for this rule | required |
actions | list[BaseAction] | A list of actions to take upon triggering | required |
exempt_roles | list[Snowflake_Type] | Roles that ignore this rule | MISSING |
exempt_channels | list[Snowflake_Type] | Channels that ignore this role | MISSING |
enabled | bool | Is this rule enabled? | True |
event_type | AutoModEvent | The type of event that triggers this rule | AutoModEvent.MESSAGE_SEND |
Returns:
| Type | Description |
|---|---|
AutoModRule | The created rule |
Source code in naff/models/discord/guild.py
1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | |
fetch_auto_moderation_rules() async ¶
Get this guild's auto moderation rules.
Returns:
| Type | Description |
|---|---|
List[AutoModRule] | A list of auto moderation rules |
Source code in naff/models/discord/guild.py
1699 1700 1701 1702 1703 1704 1705 1706 1707 | |
delete_auto_moderation_rule(rule, reason=MISSING) async ¶
Delete a given auto moderation rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rule | Snowflake_Type | The rule to delete | required |
reason | Absent[str] | The reason for deleting this rule | MISSING |
Source code in naff/models/discord/guild.py
1709 1710 1711 1712 1713 1714 1715 1716 1717 | |
modify_auto_moderation_rule(rule, *, name=MISSING, trigger=MISSING, trigger_type=MISSING, trigger_metadata=MISSING, actions=MISSING, exempt_channels=MISSING, exempt_roles=MISSING, event_type=MISSING, enabled=MISSING, reason=MISSING) async ¶
Modify an existing automod rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rule | Snowflake_Type | The rule to modify | required |
name | Absent[str] | The name of the rule | MISSING |
trigger | Absent[BaseTrigger] | A trigger for this rule | MISSING |
trigger_type | Absent[AutoModTriggerType] | The type trigger for this rule (ignored if trigger specified) | MISSING |
trigger_metadata | Absent[dict] | Metadata for the trigger (ignored if trigger specified) | MISSING |
actions | Absent[list[BaseAction]] | A list of actions to take upon triggering | MISSING |
exempt_roles | Absent[list[Snowflake_Type]] | Roles that ignore this rule | MISSING |
exempt_channels | Absent[list[Snowflake_Type]] | Channels that ignore this role | MISSING |
enabled | Absent[bool] | Is this rule enabled? | MISSING |
event_type | Absent[AutoModEvent] | The type of event that triggers this rule | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Returns:
| Type | Description |
|---|---|
AutoModRule | The updated rule |
Source code in naff/models/discord/guild.py
1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 | |
unban(user, reason=MISSING) async ¶
Unban a user from the guild.
Note
You must have the ban members permission
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user | Union[User, Member, Snowflake_Type] | The user to unban | required |
reason | Absent[str] | The reason for the ban | MISSING |
Source code in naff/models/discord/guild.py
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 | |
fetch_widget_image(style=None) async ¶
Fetch a guilds widget image.
For a list of styles, look here: https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style | str | The style to use for the widget image | None |
Returns:
| Type | Description |
|---|---|
str | The URL of the widget image. |
Source code in naff/models/discord/guild.py
1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 | |
fetch_widget_settings() async ¶
Fetches the guilds widget settings.
Returns:
| Type | Description |
|---|---|
GuildWidgetSettings | The guilds widget settings object. |
Source code in naff/models/discord/guild.py
1804 1805 1806 1807 1808 1809 1810 1811 1812 | |
fetch_widget() async ¶
Fetches the guilds widget.
Returns:
| Type | Description |
|---|---|
GuildWidget | The guilds widget object. |
Source code in naff/models/discord/guild.py
1814 1815 1816 1817 1818 1819 1820 1821 1822 | |
modify_widget(enabled=MISSING, channel=MISSING, settings=MISSING) async ¶
Modify the guild's widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled | Absent[bool] | Should the widget be enabled? | MISSING |
channel | Absent[Union[TYPE_GUILD_CHANNEL, Snowflake_Type]] | The channel to use in the widget | MISSING |
settings | Absent[GuildWidgetSettings] | The settings to use for the widget | MISSING |
Returns:
| Type | Description |
|---|---|
GuildWidget | The updated guilds widget object. |
Source code in naff/models/discord/guild.py
1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 | |
fetch_invites() async ¶
Fetches all invites for the guild.
Returns:
| Type | Description |
|---|---|
List[Invite] | A list of invites for the guild. |
Source code in naff/models/discord/guild.py
1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 | |
fetch_guild_integrations() async ¶
Fetches all integrations for the guild.
Returns:
| Type | Description |
|---|---|
List[GuildIntegration] | A list of integrations for the guild. |
Source code in naff/models/discord/guild.py
1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 | |
search_members(query, limit=1) async ¶
Search for members in the guild whose username or nickname starts with a provided string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query | str | Query string to match username(s) and nickname(s) against. | required |
limit | int | Max number of members to return (1-1000) | 1 |
Returns:
| Type | Description |
|---|---|
List[Member] | A list of members matching the query. |
Source code in naff/models/discord/guild.py
1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 | |
fetch_voice_regions() async ¶
Fetches the voice regions for the guild.
Unlike the NAFF.fetch_voice_regions method, this will returns VIP servers when the guild is VIP-enabled.
Returns:
| Type | Description |
|---|---|
List[VoiceRegion] | A list of voice regions. |
Source code in naff/models/discord/guild.py
1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 | |
gui_sorted_channels() property ¶
Return this guilds channels sorted by their gui positions
Source code in naff/models/discord/guild.py
1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 | |
get_channel_gui_position(channel_id) ¶
Get a given channels gui position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get the gui position for. | required |
Returns:
| Type | Description |
|---|---|
int | The gui position of the channel. |
Source code in naff/models/discord/guild.py
1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 | |
GuildTemplate ¶
Bases: ClientObject
Source code in naff/models/discord/guild.py
1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 | |
synchronise() async ¶
Synchronise the template to the source guild's current state.
Source code in naff/models/discord/guild.py
2002 2003 2004 2005 2006 | |
modify(name=MISSING, description=MISSING) async ¶
Modify the template's metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | The name for the template | MISSING |
description | Absent[str] | The description for the template | MISSING |
Returns:
| Type | Description |
|---|---|
GuildTemplate | The modified template object. |
Source code in naff/models/discord/guild.py
2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 | |
delete() async ¶
Delete the guild template.
Source code in naff/models/discord/guild.py
2026 2027 2028 | |
GuildIntegration ¶
Bases: DiscordObject
Source code in naff/models/discord/guild.py
2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 | |
name: str = field(repr=True) class-attribute ¶
The name of the integration
type: str = field(repr=True) class-attribute ¶
integration type (twitch, youtube, or discord)
enabled: bool = field(repr=True) class-attribute ¶
is this integration enabled
account: dict = field() class-attribute ¶
integration account information
application: Optional[models.Application] = field(default=None) class-attribute ¶
The bot/OAuth2 application for discord integrations
syncing: Optional[bool] = field(default=MISSING) class-attribute ¶
is this integration syncing
role_id: Optional[Snowflake_Type] = field(default=MISSING) class-attribute ¶
id that this integration uses for "subscribers"
enable_emoticons: bool = field(default=MISSING) class-attribute ¶
whether emoticons should be synced for this integration (twitch only currently)
expire_behavior: IntegrationExpireBehaviour = field(default=MISSING, converter=optional(IntegrationExpireBehaviour)) class-attribute ¶
the behavior of expiring subscribers
expire_grace_period: int = field(default=MISSING) class-attribute ¶
the grace period (in days) before expiring subscribers
user: models.BaseUser = field(default=MISSING) class-attribute ¶
user for this integration
synced_at: models.Timestamp = field(default=MISSING, converter=optional(timestamp_converter)) class-attribute ¶
when this integration was last synced
subscriber_count: int = field(default=MISSING) class-attribute ¶
how many subscribers this integration has
revoked: bool = field(default=MISSING) class-attribute ¶
has this integration been revoked
delete(reason=MISSING) async ¶
Delete this guild integration.
Source code in naff/models/discord/guild.py
2084 2085 2086 | |
GuildWidgetSettings ¶
Bases: DictSerializationMixin
Source code in naff/models/discord/guild.py
2089 2090 2091 2092 2093 | |
GuildWidget ¶
Bases: DiscordObject
Source code in naff/models/discord/guild.py
2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 | |
name: str = field(repr=True) class-attribute ¶
Guild name (2-100 characters)
instant_invite: str = field(repr=True, default=None) class-attribute ¶
Instant invite for the guilds specified widget invite channel
presence_count: int = field(repr=True, default=0) class-attribute ¶
Number of online members in this guild
get_channels() ¶
Gets voice and stage channels which are accessible by @everyone
Returns:
| Type | Description |
|---|---|
List[TYPE_VOICE_CHANNEL] | List of channels |
Source code in naff/models/discord/guild.py
2117 2118 2119 2120 2121 2122 2123 2124 2125 | |
fetch_channels() async ¶
Gets voice and stage channels which are accessible by @everyone. Fetches the channels from API if they are not cached.
Returns:
| Type | Description |
|---|---|
List[TYPE_VOICE_CHANNEL] | List of channels |
Source code in naff/models/discord/guild.py
2127 2128 2129 2130 2131 2132 2133 2134 2135 | |
get_members() ¶
Gets special widget user objects that includes users presence (Limit 100)
Returns:
| Type | Description |
|---|---|
List[User] | List of users |
Source code in naff/models/discord/guild.py
2137 2138 2139 2140 2141 2142 2143 2144 2145 | |
fetch_members() async ¶
Gets special widget user objects that includes users presence (Limit 100). Fetches the users from API if they are not cached.
Returns:
| Type | Description |
|---|---|
List[User] | List of users |
Source code in naff/models/discord/guild.py
2147 2148 2149 2150 2151 2152 2153 2154 2155 | |
AuditLogChange ¶
Bases: ClientObject
Source code in naff/models/discord/guild.py
2158 2159 2160 2161 2162 2163 2164 2165 | |
key: str = field(repr=True) class-attribute ¶
name of audit log change key
new_value: Optional[Union[list, str, int, bool, Snowflake_Type]] = field(default=MISSING) class-attribute ¶
new value of the key
old_value: Optional[Union[list, str, int, bool, Snowflake_Type]] = field(default=MISSING) class-attribute ¶
old value of the key
AuditLogEntry ¶
Bases: DiscordObject
Source code in naff/models/discord/guild.py
2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 | |
target_id: Optional[Snowflake_Type] = field(converter=optional(to_snowflake)) class-attribute ¶
id of the affected entity (webhook, user, role, etc.)
user_id: Snowflake_Type = field(converter=optional(to_snowflake)) class-attribute ¶
the user who made the changes
action_type: AuditLogEventType = field(converter=AuditLogEventType) class-attribute ¶
type of action that occurred
changes: Optional[List[AuditLogChange]] = field(default=MISSING) class-attribute ¶
changes made to the target_id
options: Optional[Union[Snowflake_Type, str]] = field(default=MISSING) class-attribute ¶
additional info for certain action types
reason: Optional[str] = field(default=MISSING) class-attribute ¶
the reason for the change (0-512 characters)
AuditLog ¶
Bases: ClientObject
Contains entries and other data given from selected
Source code in naff/models/discord/guild.py
2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 | |
application_commands: list[InteractionCommand] = field(factory=list, converter=optional(deserialize_app_cmds)) class-attribute ¶
list of application commands that have had their permissions updated
entries: Optional[List[AuditLogEntry]] = field(default=MISSING) class-attribute ¶
list of audit log entries
scheduled_events: Optional[List[models.ScheduledEvent]] = field(default=MISSING) class-attribute ¶
list of guild scheduled events found in the audit log
integrations: Optional[List[GuildIntegration]] = field(default=MISSING) class-attribute ¶
list of partial integration objects
threads: Optional[List[models.ThreadChannel]] = field(default=MISSING) class-attribute ¶
list of threads found in the audit log
users: Optional[List[models.User]] = field(default=MISSING) class-attribute ¶
list of users found in the audit log
webhooks: Optional[List[models.Webhook]] = field(default=MISSING) class-attribute ¶
list of webhooks found in the audit log
AuditLogHistory ¶
Bases: AsyncIterator
An async iterator for searching through a audit log's entry history.
Attributes:
| Name | Type | Description |
|---|---|---|
guild | ||
user_id | ||
action_type | ||
before | Snowflake_Type | get messages before this message ID |
after | Snowflake_Type | get messages after this message ID |
limit | Snowflake_Type | The maximum number of entries to return (set to 0 for no limit) |
Source code in naff/models/discord/guild.py
2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 | |
fetch() async ¶
Retrieves the audit log entries from discord API.
Returns:
| Type | Description |
|---|---|
List[AuditLog] | The list of audit log entries. |
Source code in naff/models/discord/guild.py
2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 | |
ScheduledEvent ¶
Bases: DiscordObject
Source code in naff/models/discord/scheduled_event.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
entity_type: Union[ScheduledEventType, int] = field(converter=ScheduledEventType) class-attribute ¶
The type of the scheduled event
start_time: Timestamp = field(converter=timestamp_converter) class-attribute ¶
A Timestamp object representing the scheduled start time of the event
end_time: Optional[Timestamp] = field(default=None, converter=optional(timestamp_converter)) class-attribute ¶
Optional Timstamp object representing the scheduled end time, required if entity_type is EXTERNAL
privacy_level: Union[ScheduledEventPrivacyLevel, int] = field(converter=ScheduledEventPrivacyLevel) class-attribute ¶
Privacy level of the scheduled event
Note
Discord only has GUILD_ONLY at the momment.
status: Union[ScheduledEventStatus, int] = field(converter=ScheduledEventStatus) class-attribute ¶
Current status of the scheduled event
entity_id: Optional[Snowflake_Type] = field(default=MISSING, converter=optional(to_snowflake)) class-attribute ¶
The id of an entity associated with a guild scheduled event
entity_metadata: Optional[Dict[str, Any]] = field(default=MISSING) class-attribute ¶
The metadata associated with the entity_type
user_count: int = field(default=MISSING) class-attribute ¶
Amount of users subscribed to the scheduled event
cover: Asset | None = field(default=None) class-attribute ¶
The cover image of this event
creator() async property ¶
Returns the user who created this event.
Note
Events made before October 25th, 2021 will not have a creator.
Source code in naff/models/discord/scheduled_event.py
59 60 61 62 63 64 65 66 67 68 | |
location() property ¶
Returns the external locatian of this event.
Source code in naff/models/discord/scheduled_event.py
95 96 97 98 99 100 | |
fetch_channel() async ¶
Returns the channel this event is scheduled in if it is scheduled in a channel.
Source code in naff/models/discord/scheduled_event.py
102 103 104 105 106 | |
get_channel() ¶
Returns the channel this event is scheduled in if it is scheduled in a channel.
Source code in naff/models/discord/scheduled_event.py
108 109 110 111 112 113 | |
fetch_event_users(limit=100, with_member_data=False, before=MISSING, after=MISSING) async ¶
Fetch event users.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | Optional[int] | Discord defualts to 100 | 100 |
with_member_data | bool | Whether to include guild member data | False |
before | Absent[Optional[Snowflake_Type]] | Snowflake of a user to get before | MISSING |
after | Absent[Optional[Snowflake_Type]] | Snowflake of a user to get after | MISSING |
Note
This method is paginated
Source code in naff/models/discord/scheduled_event.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
delete(reason=MISSING) async ¶
Deletes this event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason | Absent[str] | The reason for deleting this event | MISSING |
Source code in naff/models/discord/scheduled_event.py
148 149 150 151 152 153 154 155 156 | |
edit(name=MISSING, start_time=MISSING, end_time=MISSING, status=MISSING, description=MISSING, channel_id=MISSING, event_type=MISSING, external_location=MISSING, entity_metadata=MISSING, privacy_level=MISSING, cover_image=MISSING, reason=MISSING) async ¶
Edits this event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | The name of the event | MISSING |
description | Absent[str] | The description of the event | MISSING |
channel_id | Absent[Optional[Snowflake_Type]] | The channel id of the event | MISSING |
event_type | Absent[ScheduledEventType] | The type of the event | MISSING |
start_time | Absent[Timestamp] | The scheduled start time of the event | MISSING |
end_time | Absent[Timestamp] | The scheduled end time of the event | MISSING |
status | Absent[ScheduledEventStatus] | The status of the event | MISSING |
entity_metadata | Absent[dict] | The metadata of the event | MISSING |
privacy_level | Absent[ScheduledEventPrivacyLevel] | The privacy level of the event | MISSING |
cover_image | Absent[UPLOADABLE_TYPE] | the cover image of the scheduled event | MISSING |
reason | Absent[str] | The reason for editing the event | MISSING |
Note
If updating event_type to EXTERNAL: channel_id is required and must be set to null
1 2 3 | |
Source code in naff/models/discord/scheduled_event.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
StickerTypes ¶
Bases: IntEnum
Types of sticker.
Source code in naff/models/discord/sticker.py
19 20 21 22 23 24 25 | |
StickerFormatTypes ¶
Bases: IntEnum
File formats for stickers.
Source code in naff/models/discord/sticker.py
28 29 30 31 32 33 | |
StickerItem ¶
Bases: DiscordObject
Source code in naff/models/discord/sticker.py
36 37 38 39 40 41 | |
Sticker ¶
Bases: StickerItem
Represents a sticker that can be sent in messages.
Source code in naff/models/discord/sticker.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
pack_id: Optional[Snowflake_Type] = field(default=None, converter=optional(to_snowflake)) class-attribute ¶
For standard stickers, id of the pack the sticker is from.
description: Optional[str] = field(default=None) class-attribute ¶
Description of the sticker.
tags: str = field() class-attribute ¶
autocomplete/suggestion tags for the sticker (max 200 characters)
type: Union[StickerTypes, int] = field(converter=StickerTypes) class-attribute ¶
Type of sticker.
available: Optional[bool] = field(default=True) class-attribute ¶
Whether this guild sticker can be used, may be false due to loss of Server Boosts.
sort_value: Optional[int] = field(default=None) class-attribute ¶
The standard sticker's sort order within its pack.
fetch_creator() async ¶
Fetch the user who created this emoji.
Returns:
| Type | Description |
|---|---|
User | User object |
Source code in naff/models/discord/sticker.py
64 65 66 67 68 69 70 71 72 | |
get_creator() ¶
Get the user who created this emoji.
Returns:
| Type | Description |
|---|---|
User | User object |
Source code in naff/models/discord/sticker.py
74 75 76 77 78 79 80 81 82 | |
fetch_guild() async ¶
Fetch the guild associated with this emoji.
Returns:
| Type | Description |
|---|---|
Guild | Guild object |
Source code in naff/models/discord/sticker.py
84 85 86 87 88 89 90 91 92 | |
get_guild() ¶
Get the guild associated with this emoji.
Returns:
| Type | Description |
|---|---|
Guild | Guild object |
Source code in naff/models/discord/sticker.py
94 95 96 97 98 99 100 101 102 | |
edit(name=MISSING, description=MISSING, tags=MISSING, reason=MISSING) async ¶
Edit a sticker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[Optional[str]] | New name of the sticker | MISSING |
description | Absent[Optional[str]] | New description of the sticker | MISSING |
tags | Absent[Optional[str]] | New tags of the sticker | MISSING |
reason | Absent[Optional[str]] | Reason for the edit | MISSING |
Returns:
| Type | Description |
|---|---|
Sticker | The updated sticker instance |
Source code in naff/models/discord/sticker.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
delete(reason=MISSING) async ¶
Delete a sticker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason | Optional[str] | Reason for the deletion | MISSING |
Raises:
| Type | Description |
|---|---|
ValueError | If you attempt to delete a non-guild sticker |
Source code in naff/models/discord/sticker.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
StickerPack ¶
Bases: DiscordObject
Represents a pack of standard stickers.
Source code in naff/models/discord/sticker.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
stickers: List[Sticker] = field(factory=list) class-attribute ¶
The stickers in the pack.
name: str = field(repr=True) class-attribute ¶
Name of the sticker pack.
sku_id: Snowflake_Type = field(repr=True) class-attribute ¶
id of the pack's SKU.
cover_sticker_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
id of a sticker in the pack which is shown as the pack's icon.
description: str = field() class-attribute ¶
Description of the sticker pack.
banner_asset_id: Snowflake_Type = field() class-attribute ¶
id of the sticker pack's banner image.
WebhookTypes ¶
Bases: IntEnum
Source code in naff/models/discord/webhooks.py
33 34 35 36 37 38 39 | |
INCOMING = 1 class-attribute ¶
Incoming Webhooks can post messages to channels with a generated token
CHANNEL_FOLLOWER = 2 class-attribute ¶
Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels
APPLICATION = 3 class-attribute ¶
Application webhooks are webhooks used with Interactions
Webhook ¶
Bases: DiscordObject, SendMixin
Source code in naff/models/discord/webhooks.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
type: WebhookTypes = field() class-attribute ¶
The type of webhook
application_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
the bot/OAuth2 application that created this webhook
guild_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
the guild id this webhook is for, if any
channel_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
the channel id this webhook is for, if any
user_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
the user this webhook was created by
name: Optional[str] = field(default=None) class-attribute ¶
the default name of the webhook
avatar: Optional[str] = field(default=None) class-attribute ¶
the default user avatar hash of the webhook
token: str = field(default=MISSING) class-attribute ¶
the secure token of the webhook (returned for Incoming Webhooks)
url: Optional[str] = field(default=None) class-attribute ¶
the url used for executing the webhook (returned by the webhooks OAuth2 flow)
source_guild_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
the guild of the channel that this webhook is following (returned for Channel Follower Webhooks)
source_channel_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
the channel that this webhook is following (returned for Channel Follower Webhooks)
from_url(url, client) classmethod ¶
Webhook object from a URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client | Client | The client to use to make the request. | required |
url | str | Webhook URL | required |
Returns:
| Type | Description |
|---|---|
Webhook | A Webhook object. |
Source code in naff/models/discord/webhooks.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
create(client, channel, name, avatar=MISSING) async classmethod ¶
Create a webhook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client | Client | The bot's client | required |
channel | Union[Snowflake_Type, TYPE_MESSAGEABLE_CHANNEL] | The channel to create the webhook in | required |
name | str | The name of the webhook | required |
avatar | Absent[UPLOADABLE_TYPE] | An optional default avatar to use | MISSING |
Returns:
| Type | Description |
|---|---|
Webhook | New webhook object |
Raises:
| Type | Description |
|---|---|
ValueError | If you try to name the webhook "Clyde" |
Source code in naff/models/discord/webhooks.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
edit(name=MISSING, avatar=MISSING, channel_id=MISSING) async ¶
Edit this webhook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | The default name of the webhook. | MISSING |
avatar | Absent[UPLOADABLE_TYPE] | The image for the default webhook avatar. | MISSING |
channel_id | Absent[Snowflake_Type] | The new channel id this webhook should be moved to. | MISSING |
Raises:
| Type | Description |
|---|---|
ValueError | If you try to name the webhook "Clyde" |
Source code in naff/models/discord/webhooks.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
delete() async ¶
Delete this webhook.
Source code in naff/models/discord/webhooks.py
164 165 166 | |
send(content=None, embed=None, embeds=None, components=None, stickers=None, allowed_mentions=None, reply_to=None, files=None, file=None, tts=False, suppress_embeds=False, flags=None, username=None, avatar_url=None, wait=False, thread=None, **kwargs) async ¶
Send a message as this webhook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[List[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
reply_to | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message to reference, must be from the same channel. | None |
files | Optional[Union[UPLOADABLE_TYPE, List[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
suppress_embeds | bool | Should embeds be suppressed on this send | False |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
username | str | The username to use | None |
avatar_url | str | The url of an image to use as the avatar | None |
wait | bool | Waits for confirmation of delivery. Set this to True if you intend to edit the message | False |
thread | Snowflake_Type | Send this webhook to a thread channel | None |
Returns:
| Type | Description |
|---|---|
Optional[Message] | New message object that was sent if |
Source code in naff/models/discord/webhooks.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
edit_message(message, content=None, embeds=None, components=None, stickers=None, allowed_mentions=None, reply_to=None, files=None, file=None, tts=False, flags=None) async ¶
Edit a message as this webhook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message | Union[Message, Snowflake_Type] | Message to edit | required |
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[List[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
reply_to | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message to reference, must be from the same channel. | None |
files | Optional[Union[UPLOADABLE_TYPE, List[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
Returns:
| Type | Description |
|---|---|
Optional[Message] | Updated message object that was sent if |
Source code in naff/models/discord/webhooks.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
ChannelHistory ¶
Bases: AsyncIterator
An async iterator for searching through a channel's history.
Attributes:
| Name | Type | Description |
|---|---|---|
channel | BaseChannel | The channel to search through |
limit | BaseChannel | The maximum number of messages to return (set to 0 for no limit) |
before | Snowflake_Type | get messages before this message ID |
after | Snowflake_Type | get messages after this message ID |
around | Snowflake_Type | get messages "around" this message ID |
Source code in naff/models/discord/channel.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
fetch() async ¶
Fetch additional objects.
Your implementation of this method must return a list of objects. If no more objects are available, raise QueueEmpty
Returns:
| Type | Description |
|---|---|
List[Message] | List of objects |
Raises:
| Type | Description |
|---|---|
QueueEmpty | when no more objects are available. |
Source code in naff/models/discord/channel.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
PermissionOverwrite ¶
Bases: SnowflakeObject, DictSerializationMixin
Channel Permissions Overwrite object.
Note
id here is not an attribute of the overwrite, it is the ID of the overwritten instance
Source code in naff/models/discord/channel.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
type: OverwriteTypes = field(repr=True, converter=OverwriteTypes) class-attribute ¶
Permission overwrite type (role or member)
allow: Optional[Permissions] = field(repr=True, converter=optional_c(Permissions), kw_only=True, default=None) class-attribute ¶
Permissions to allow
deny: Optional[Permissions] = field(repr=True, converter=optional_c(Permissions), kw_only=True, default=None) class-attribute ¶
Permissions to deny
for_target(target_type) classmethod ¶
Create a PermissionOverwrite for a role or member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_type | Union[Role, Member, User] | The type of the target (role or member) | required |
Returns:
| Type | Description |
|---|---|
PermissionOverwrite | PermissionOverwrite |
Source code in naff/models/discord/channel.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
add_allows(*perms) ¶
Add permissions to allow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*perms | Permissions | Permissions to add | () |
Source code in naff/models/discord/channel.py
167 168 169 170 171 172 173 174 175 176 177 178 | |
add_denies(*perms) ¶
Add permissions to deny.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*perms | Permissions | Permissions to add | () |
Source code in naff/models/discord/channel.py
180 181 182 183 184 185 186 187 188 189 190 191 | |
MessageableMixin ¶
Bases: SendMixin
Source code in naff/models/discord/channel.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
last_message_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
The id of the last message sent in this channel (may not point to an existing or valid message)
default_auto_archive_duration: int = field(default=AutoArchiveDuration.ONE_DAY) class-attribute ¶
Default duration that the clients (not the API) will use for newly created threads, in minutes, to automatically archive the thread after recent activity
last_pin_timestamp: Optional[models.Timestamp] = field(default=None, converter=optional_c(timestamp_converter)) class-attribute ¶
When the last pinned message was pinned. This may be None when a message is not pinned.
fetch_message(message_id) async ¶
Fetch a message from the channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message_id | Snowflake_Type | ID of message to retrieve. | required |
Returns:
| Type | Description |
|---|---|
Optional[Message] | The message object fetched. If the message is not found, returns None. |
Source code in naff/models/discord/channel.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
get_message(message_id) ¶
Get a message from the channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message_id | Snowflake_Type | ID of message to retrieve. | required |
Returns:
| Type | Description |
|---|---|
Message | The message object fetched. |
Source code in naff/models/discord/channel.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
history(limit=100, before=None, after=None, around=None) ¶
Get an async iterator for the history of this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | The maximum number of messages to return (set to 0 for no limit) | 100 |
before | Snowflake_Type | get messages before this message ID | None |
after | Snowflake_Type | get messages after this message ID | None |
around | Snowflake_Type | get messages "around" this message ID | None |
Example Usage:
1 2 3 4 5 | |
1 2 3 | |
Returns:
| Type | Description |
|---|---|
ChannelHistory | ChannelHistory (AsyncIterator) |
Source code in naff/models/discord/channel.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
fetch_messages(limit=50, around=MISSING, before=MISSING, after=MISSING) async ¶
Fetch multiple messages from the channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | Max number of messages to return, default | 50 |
around | Snowflake_Type | Message to get messages around | MISSING |
before | Snowflake_Type | Message to get messages before | MISSING |
after | Snowflake_Type | Message to get messages after | MISSING |
Returns:
| Type | Description |
|---|---|
List[Message] | A list of messages fetched. |
Source code in naff/models/discord/channel.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
fetch_pinned_messages() async ¶
Fetch pinned messages from the channel.
Returns:
| Type | Description |
|---|---|
List[Message] | A list of messages fetched. |
Source code in naff/models/discord/channel.py
316 317 318 319 320 321 322 323 324 325 | |
delete_messages(messages, reason=MISSING) async ¶
Bulk delete messages from channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages | List[Union[Snowflake_Type, Message]] | List of messages or message IDs to delete. | required |
reason | Absent[Optional[str]] | The reason for this action. Used for audit logs. | MISSING |
Source code in naff/models/discord/channel.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
delete_message(message, reason=None) async ¶
Delete a single message from a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message | Union[Snowflake_Type, Message] | The message to delete | required |
reason | str | The reason for this action | None |
Source code in naff/models/discord/channel.py
347 348 349 350 351 352 353 354 355 356 357 | |
purge(deletion_limit=50, search_limit=100, predicate=MISSING, avoid_loading_msg=True, before=MISSING, after=MISSING, around=MISSING, reason=MISSING) async ¶
Bulk delete messages within a channel. If a predicate is provided, it will be used to determine which messages to delete, otherwise all messages will be deleted within the deletion_limit.
Example Usage:
1 2 3 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deletion_limit | int | The target amount of messages to delete | 50 |
search_limit | int | How many messages to search through | 100 |
predicate | Callable[[Message], bool] | A function that returns True or False, and takes a message as an argument | MISSING |
avoid_loading_msg | bool | Should the bot attempt to avoid deleting its own loading messages (recommended enabled) | True |
before | Optional[Snowflake_Type] | Search messages before this ID | MISSING |
after | Optional[Snowflake_Type] | Search messages after this ID | MISSING |
around | Optional[Snowflake_Type] | Search messages around this ID | MISSING |
reason | Absent[Optional[str]] | The reason for this deletion | MISSING |
Returns:
| Type | Description |
|---|---|
int | The total amount of messages deleted |
Source code in naff/models/discord/channel.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
trigger_typing() async ¶
Trigger a typing animation in this channel.
Source code in naff/models/discord/channel.py
427 428 429 | |
typing() property ¶
A context manager to send a typing state to a given channel as long as long as the wrapped operation takes.
Source code in naff/models/discord/channel.py
431 432 433 434 | |
InvitableMixin ¶
Source code in naff/models/discord/channel.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |
create_invite(max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user=None, target_application=None, reason=None) async ¶
Creates a new channel invite.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_age | int | Max age of invite in seconds, default 86400 (24 hours). | 86400 |
max_uses | int | Max uses of invite, default 0. | 0 |
temporary | bool | Grants temporary membership, default False. | False |
unique | bool | Invite is unique, default false. | False |
target_type | Optional[InviteTargetTypes] | Target type for streams and embedded applications. | None |
target_user | Optional[Union[Snowflake_Type, User]] | Target User ID for Stream target type. | None |
target_application | Optional[Union[Snowflake_Type, Application]] | Target Application ID for Embedded App target type. | None |
reason | Optional[str] | The reason for creating this invite. | None |
Returns:
| Type | Description |
|---|---|
Invite | Newly created Invite object. |
Source code in naff/models/discord/channel.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
fetch_invites() async ¶
Fetches all invites (with invite metadata) for the channel.
Returns:
| Type | Description |
|---|---|
List[Invite] | List of Invite objects. |
Source code in naff/models/discord/channel.py
487 488 489 490 491 492 493 494 495 496 | |
ThreadableMixin ¶
Source code in naff/models/discord/channel.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
create_thread(name, message=MISSING, thread_type=MISSING, invitable=MISSING, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None) async ¶
Creates a new thread in this channel. If a message is provided, it will be used as the initial message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | 1-100 character thread name | required |
message | Absent[Snowflake_Type] | The message to connect this thread to. Required for news channel. | MISSING |
thread_type | Absent[ChannelTypes] | Is the thread private or public. Not applicable to news channel, it will always be GUILD_NEWS_THREAD. | MISSING |
invitable | Absent[bool] | whether non-moderators can add other non-moderators to a thread. Only applicable when creating a private thread. | MISSING |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
reason | Absent[str] | The reason for creating this thread. | None |
Returns:
| Type | Description |
|---|---|
TYPE_THREAD_CHANNEL | The created thread, if successful |
Source code in naff/models/discord/channel.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
fetch_public_archived_threads(limit=None, before=None) async ¶
Get a ThreadList of archived public threads available in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | optional maximum number of threads to return | None |
before | Optional[Timestamp] | Returns threads before this timestamp | None |
Returns:
| Type | Description |
|---|---|
ThreadList | A |
Source code in naff/models/discord/channel.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | |
fetch_private_archived_threads(limit=None, before=None) async ¶
Get a ThreadList of archived private threads available in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | optional maximum number of threads to return | None |
before | Optional[Timestamp] | Returns threads before this timestamp | None |
Returns:
| Type | Description |
|---|---|
ThreadList | A |
Source code in naff/models/discord/channel.py
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
fetch_archived_threads(limit=None, before=None) async ¶
Get a ThreadList of archived threads available in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | optional maximum number of threads to return | None |
before | Optional[Timestamp] | Returns threads before this timestamp | None |
Returns:
| Type | Description |
|---|---|
ThreadList | A |
Source code in naff/models/discord/channel.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
fetch_joined_private_archived_threads(limit=None, before=None) async ¶
Get a ThreadList of threads the bot is a participant of in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | optional maximum number of threads to return | None |
before | Optional[Timestamp] | Returns threads before this timestamp | None |
Returns:
| Type | Description |
|---|---|
ThreadList | A |
Source code in naff/models/discord/channel.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | |
fetch_active_threads() async ¶
Gets all active threads in the channel, including public and private threads.
Returns:
| Type | Description |
|---|---|
ThreadList | A |
Source code in naff/models/discord/channel.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
fetch_all_threads() async ¶
Gets all threads in the channel. Active and archived, including public and private threads.
Returns:
| Type | Description |
|---|---|
ThreadList | A |
Source code in naff/models/discord/channel.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
WebhookMixin ¶
Source code in naff/models/discord/channel.py
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | |
create_webhook(name, avatar=MISSING) async ¶
Create a webhook in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the webhook | required |
avatar | Absent[UPLOADABLE_TYPE] | An optional default avatar image to use | MISSING |
Returns:
| Type | Description |
|---|---|
Webhook | The created webhook object |
Raises:
| Type | Description |
|---|---|
ValueError | If you try to name the webhook "Clyde" |
Source code in naff/models/discord/channel.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | |
delete_webhook(webhook) async ¶
Delete a given webhook in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webhook | Webhook | The webhook to delete | required |
Source code in naff/models/discord/channel.py
694 695 696 697 698 699 700 701 702 | |
fetch_webhooks() async ¶
Fetches all the webhooks for this channel.
Returns:
| Type | Description |
|---|---|
List[Webhook] | List of webhook objects |
Source code in naff/models/discord/channel.py
704 705 706 707 708 709 710 711 712 713 | |
BaseChannel ¶
Bases: DiscordObject
Source code in naff/models/discord/channel.py
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 | |
name: Optional[str] = field(repr=True, default=None) class-attribute ¶
The name of the channel (1-100 characters)
type: Union[ChannelTypes, int] = field(repr=True, converter=ChannelTypes) class-attribute ¶
The channel topic (0-1024 characters)
from_dict_factory(data, client) classmethod ¶
Creates a channel object of the appropriate type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data | dict | The channel data. | required |
client | Client | The bot. | required |
Returns:
| Type | Description |
|---|---|
TYPE_ALL_CHANNEL | The new channel object. |
Source code in naff/models/discord/channel.py
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | |
mention() property ¶
Returns a string that would mention the channel.
Source code in naff/models/discord/channel.py
744 745 746 747 | |
edit(name=MISSING, icon=MISSING, type=MISSING, position=MISSING, topic=MISSING, nsfw=MISSING, rate_limit_per_user=MISSING, bitrate=MISSING, user_limit=MISSING, permission_overwrites=MISSING, parent_id=MISSING, rtc_region=MISSING, video_quality_mode=MISSING, default_auto_archive_duration=MISSING, archived=MISSING, auto_archive_duration=MISSING, locked=MISSING, invitable=MISSING, reason=MISSING, **kwargs) async ¶
Edits the channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
icon | Absent[UPLOADABLE_TYPE] | DM Group icon | MISSING |
type | Absent[ChannelTypes] | The type of channel; only conversion between text and news is supported and only in guilds with the "NEWS" feature | MISSING |
position | Absent[int] | The position of the channel in the left-hand listing | MISSING |
topic | Absent[str] | 0-1024 character channel topic | MISSING |
nsfw | Absent[bool] | Whether the channel is nsfw | MISSING |
rate_limit_per_user | Absent[int] | Amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
bitrate | Absent[int] | The bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers) | MISSING |
user_limit | Absent[int] | The user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Channel or category-specific permissions | MISSING |
parent_id | Absent[Snowflake_Type] | The id of the new parent category for a channel | MISSING |
rtc_region | Absent[Union[VoiceRegion, str]] | Channel voice region id, automatic when set to None. | MISSING |
video_quality_mode | Absent[VideoQualityModes] | The camera video quality mode of the voice channel | MISSING |
default_auto_archive_duration | Absent[AutoArchiveDuration] | The default duration that the clients use (not the API) for newly created threads in the channel, in minutes, to automatically archive the thread after recent activity | MISSING |
archived | Absent[bool] | Whether the thread is archived | MISSING |
auto_archive_duration | Absent[AutoArchiveDuration] | Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | MISSING |
locked | Absent[bool] | Whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | MISSING |
invitable | Absent[bool] | Whether non-moderators can add other non-moderators to a thread; only available on private threads | MISSING |
reason | Absent[str] | The reason for editing the channel | MISSING |
Returns:
| Type | Description |
|---|---|
TYPE_ALL_CHANNEL | The edited channel. May be a new object if the channel type changes. |
Source code in naff/models/discord/channel.py
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | |
delete(reason=MISSING) async ¶
Delete this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason | Absent[Optional[str]] | The reason for deleting this channel | MISSING |
Source code in naff/models/discord/channel.py
831 832 833 834 835 836 837 838 839 | |
DMChannel ¶
Bases: BaseChannel, MessageableMixin
Source code in naff/models/discord/channel.py
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 | |
recipients: List[models.User] = field(factory=list) class-attribute ¶
The users of the DM that will receive messages sent
members() property ¶
Returns a list of users that are in this DM channel.
Source code in naff/models/discord/channel.py
861 862 863 864 | |
DM ¶
Bases: DMChannel
Source code in naff/models/discord/channel.py
867 868 869 870 871 872 | |
recipient() property ¶
Returns the user that is in this DM channel.
Source code in naff/models/discord/channel.py
869 870 871 872 | |
DMGroup ¶
Bases: DMChannel
Source code in naff/models/discord/channel.py
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 | |
owner_id: Snowflake_Type = field(repr=True) class-attribute ¶
id of the creator of the group DM
application_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
Application id of the group DM creator if it is bot-created
edit(name=MISSING, icon=MISSING, reason=MISSING, **kwargs) async ¶
Edit this DM Channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
icon | Absent[UPLOADABLE_TYPE] | An icon to use | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Source code in naff/models/discord/channel.py
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 | |
fetch_owner() async ¶
Fetch the owner of this DM group
Source code in naff/models/discord/channel.py
899 900 901 | |
get_owner() ¶
Get the owner of this DM group
Source code in naff/models/discord/channel.py
903 904 905 | |
add_recipient(user, access_token, nickname=MISSING) async ¶
Add a recipient to this DM Group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user | Union[User, Snowflake_Type] | The user to add | required |
access_token | str | access token of a user that has granted your app the gdm.join scope | required |
nickname | Absent[Optional[str]] | nickname to apply to the user being added | MISSING |
Source code in naff/models/discord/channel.py
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 | |
remove_recipient(user) async ¶
Remove a recipient from this DM Group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user | Union[User, Snowflake_Type] | The user to remove | required |
Source code in naff/models/discord/channel.py
923 924 925 926 927 928 929 930 931 932 933 | |
GuildChannel ¶
Bases: BaseChannel
Source code in naff/models/discord/channel.py
940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | |
position: Optional[int] = field(default=0) class-attribute ¶
Sorting position of the channel
nsfw: bool = field(default=False) class-attribute ¶
Whether the channel is nsfw
parent_id: Optional[Snowflake_Type] = field(default=None, converter=optional_c(to_snowflake)) class-attribute ¶
id of the parent category for a channel (each parent category can contain up to 50 channels)
permission_overwrites: list[PermissionOverwrite] = field(factory=list) class-attribute ¶
A list of the overwritten permissions for the members and roles
guild() property ¶
The guild this channel belongs to.
Source code in naff/models/discord/channel.py
953 954 955 956 | |
category() property ¶
The parent category of this channel.
Source code in naff/models/discord/channel.py
958 959 960 961 | |
gui_position() property ¶
The position of this channel in the Discord interface.
Source code in naff/models/discord/channel.py
963 964 965 966 | |
permissions_for(instance) ¶
Calculates permissions for an instance
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance | Snowflake_Type | Member or Role instance (or its ID) | required |
Returns:
| Type | Description |
|---|---|
Permissions | Permissions data |
Raises:
| Type | Description |
|---|---|
ValueError | If could not find any member or role by given ID |
RuntimeError | If given instance is from another guild |
Source code in naff/models/discord/channel.py
975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 | |
add_permission(target, type=None, allow=None, deny=None, reason=None) async ¶
Add a permission to this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target | Union[PermissionOverwrite, Role, User, Member, Snowflake_Type] | The updated PermissionOverwrite object, or the Role or User object/id to update | required |
type | Optional[OverwriteTypes] | The type of permission overwrite. Only applicable if target is an id | None |
allow | Optional[List[Permissions] | int] | List of permissions to allow. Only applicable if target is not an PermissionOverwrite object | None |
deny | Optional[List[Permissions] | int] | List of permissions to deny. Only applicable if target is not an PermissionOverwrite object | None |
reason | Optional[str] | The reason for this change | None |
Raises:
| Type | Description |
|---|---|
ValueError | Invalid target for permission |
Source code in naff/models/discord/channel.py
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 | |
edit_permission(overwrite, reason=None) async ¶
Edit the permissions for this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overwrite | PermissionOverwrite | The permission overwrite to apply | required |
reason | Optional[str] | The reason for this change | None |
Source code in naff/models/discord/channel.py
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | |
delete_permission(target, reason=MISSING) async ¶
Delete a permission overwrite for this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target | Union[PermissionOverwrite, Role, User] | The permission overwrite to delete | required |
reason | Absent[Optional[str]] | The reason for this change | MISSING |
Source code in naff/models/discord/channel.py
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 | |
set_permission(target, *, add_reactions=None, administrator=None, attach_files=None, ban_members=None, change_nickname=None, connect=None, create_instant_invite=None, deafen_members=None, embed_links=None, kick_members=None, manage_channels=None, manage_emojis_and_stickers=None, manage_events=None, manage_guild=None, manage_messages=None, manage_nicknames=None, manage_roles=None, manage_threads=None, manage_webhooks=None, mention_everyone=None, moderate_members=None, move_members=None, mute_members=None, priority_speaker=None, read_message_history=None, request_to_speak=None, send_messages=None, send_messages_in_threads=None, send_tts_messages=None, speak=None, start_embedded_activities=None, stream=None, use_application_commands=None, use_external_emojis=None, use_external_stickers=None, use_private_threads=None, use_public_threads=None, use_vad=None, view_audit_log=None, view_channel=None, view_guild_insights=None, reason=None) async ¶
Set the Permission Overwrites for a given target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target | Union[Role, Member, User] | The target to set permission overwrites for | required |
add_reactions | bool | None | Allows for the addition of reactions to messages | None |
administrator | bool | None | Allows all permissions and bypasses channel permission overwrites | None |
attach_files | bool | None | Allows for uploading images and files | None |
ban_members | bool | None | Allows banning members | None |
change_nickname | bool | None | Allows for modification of own nickname | None |
connect | bool | None | Allows for joining of a voice channel | None |
create_instant_invite | bool | None | Allows creation of instant invites | None |
deafen_members | bool | None | Allows for deafening of members in a voice channel | None |
embed_links | bool | None | Links sent by users with this permission will be auto-embedded | None |
kick_members | bool | None | Allows kicking members | None |
manage_channels | bool | None | Allows management and editing of channels | None |
manage_emojis_and_stickers | bool | None | Allows management and editing of emojis and stickers | None |
manage_events | bool | None | Allows for creating, editing, and deleting scheduled events | None |
manage_guild | bool | None | Allows management and editing of the guild | None |
manage_messages | bool | None | Allows for deletion of other users messages | None |
manage_nicknames | bool | None | Allows for modification of other users nicknames | None |
manage_roles | bool | None | Allows management and editing of roles | None |
manage_threads | bool | None | Allows for deleting and archiving threads, and viewing all private threads | None |
manage_webhooks | bool | None | Allows management and editing of webhooks | None |
mention_everyone | bool | None | Allows for using the | None |
moderate_members | bool | None | Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels | None |
move_members | bool | None | Allows for moving of members between voice channels | None |
mute_members | bool | None | Allows for muting members in a voice channel | None |
priority_speaker | bool | None | Allows for using priority speaker in a voice channel | None |
read_message_history | bool | None | Allows for reading of message history | None |
request_to_speak | bool | None | Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.) | None |
send_messages | bool | None | Allows for sending messages in a channel (does not allow sending messages in threads) | None |
send_messages_in_threads | bool | None | Allows for sending messages in threads | None |
send_tts_messages | bool | None | Allows for sending of | None |
speak | bool | None | Allows for speaking in a voice channel | None |
start_embedded_activities | bool | None | Allows for using Activities (applications with the | None |
stream | bool | None | Allows the user to go live | None |
use_application_commands | bool | None | Allows members to use application commands, including slash commands and context menu commands | None |
use_external_emojis | bool | None | Allows the usage of custom emojis from other servers | None |
use_external_stickers | bool | None | Allows the usage of custom stickers from other servers | None |
use_private_threads | bool | None | Allows for creating private threads | None |
use_public_threads | bool | None | Allows for creating public and announcement threads | None |
use_vad | bool | None | Allows for using voice-activity-detection in a voice channel | None |
view_audit_log | bool | None | Allows for viewing of audit logs | None |
view_channel | bool | None | Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels | None |
view_guild_insights | bool | None | Allows for viewing guild insights | None |
reason | str | The reason for creating this overwrite | None |
Source code in naff/models/discord/channel.py
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 | |
members() property ¶
Returns a list of members that can see this channel.
Source code in naff/models/discord/channel.py
1216 1217 1218 1219 | |
bots() property ¶
Returns a list of bots that can see this channel.
Source code in naff/models/discord/channel.py
1221 1222 1223 1224 | |
humans() property ¶
Returns a list of humans that can see this channel.
Source code in naff/models/discord/channel.py
1226 1227 1228 1229 | |
clone(name=None, reason=MISSING) async ¶
Clone this channel and create a new one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Optional[str] | The name of the new channel. Defaults to the current name | None |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
TYPE_GUILD_CHANNEL | The newly created channel. |
Source code in naff/models/discord/channel.py
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | |
GuildCategory ¶
Bases: GuildChannel
Source code in naff/models/discord/channel.py
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 | |
channels() property ¶
Get all channels within the category
Source code in naff/models/discord/channel.py
1260 1261 1262 1263 | |
voice_channels() property ¶
Get all voice channels within the category
Source code in naff/models/discord/channel.py
1265 1266 1267 1268 1269 1270 1271 1272 | |
stage_channels() property ¶
Get all stage channels within the category
Source code in naff/models/discord/channel.py
1274 1275 1276 1277 | |
text_channels() property ¶
Get all text channels within the category
Source code in naff/models/discord/channel.py
1279 1280 1281 1282 | |
news_channels() property ¶
Get all news channels within the category
Source code in naff/models/discord/channel.py
1284 1285 1286 1287 | |
edit(name=MISSING, position=MISSING, permission_overwrites=MISSING, reason=MISSING, **kwargs) async ¶
Edit this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
position | Absent[int] | the position of the channel in the left-hand listing | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | channel or category-specific permissions | MISSING |
reason | Absent[str] | the reason for this change | MISSING |
Returns:
| Type | Description |
|---|---|
GuildCategory | The updated channel object. |
Source code in naff/models/discord/channel.py
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | |
create_channel(channel_type, name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, nsfw=False, bitrate=64000, user_limit=0, rate_limit_per_user=0, reason=MISSING) async ¶
Create a guild channel within this category, allows for explicit channel type setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_type | Union[ChannelTypes, int] | The type of channel to create | required |
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
nsfw | bool | Should this channel be marked nsfw | False |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
TYPE_GUILD_CHANNEL | The newly created channel. |
Source code in naff/models/discord/channel.py
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 | |
create_text_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, nsfw=False, rate_limit_per_user=0, reason=MISSING) async ¶
Create a text channel in this guild within this category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
nsfw | bool | Should this channel be marked nsfw | False |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildText | The newly created text channel. |
Source code in naff/models/discord/channel.py
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 | |
create_news_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, nsfw=False, reason=MISSING) async ¶
Create a news channel in this guild within this category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
nsfw | bool | Should this channel be marked nsfw | False |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildNews | The newly created news channel. |
Source code in naff/models/discord/channel.py
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 | |
create_voice_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, nsfw=False, bitrate=64000, user_limit=0, reason=MISSING) async ¶
Create a guild voice channel within this category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
nsfw | bool | Should this channel be marked nsfw | False |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildVoice | The newly created voice channel. |
Source code in naff/models/discord/channel.py
1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 | |
create_stage_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, bitrate=64000, user_limit=0, reason=MISSING) async ¶
Create a guild stage channel within this category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
| Type | Description |
|---|---|
GuildStageVoice | The newly created stage channel. |
Source code in naff/models/discord/channel.py
1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 | |
GuildNews ¶
Bases: GuildChannel, MessageableMixin, InvitableMixin, ThreadableMixin, WebhookMixin
Source code in naff/models/discord/channel.py
1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 | |
topic: Optional[str] = field(default=None) class-attribute ¶
The channel topic (0-1024 characters)
edit(name=MISSING, position=MISSING, permission_overwrites=MISSING, parent_id=MISSING, nsfw=MISSING, topic=MISSING, channel_type=MISSING, default_auto_archive_duration=MISSING, reason=MISSING, **kwargs) async ¶
Edit the guild text channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
position | Absent[int] | the position of the channel in the left-hand listing | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | a list of PermissionOverwrite | MISSING |
parent_id | Absent[Snowflake_Type] | the parent category | MISSING |
nsfw | Absent[bool] | whether the channel is nsfw | MISSING |
topic | Absent[str] | 0-1024 character channel topic | MISSING |
channel_type | Absent[ChannelTypes] | the type of channel; only conversion between text and news is supported and only in guilds with the "NEWS" feature | MISSING |
default_auto_archive_duration | Absent[AutoArchiveDuration] | optional AutoArchiveDuration | MISSING |
reason | Absent[str] | An optional reason for the audit log | MISSING |
Returns:
| Type | Description |
|---|---|
Union[GuildNews, GuildText] | The edited channel. |
Source code in naff/models/discord/channel.py
1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 | |
follow(webhook_channel_id) async ¶
Follow this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webhook_channel_id | Snowflake_Type | The ID of the channel to post messages from this channel to | required |
Source code in naff/models/discord/channel.py
1576 1577 1578 1579 1580 1581 1582 1583 1584 | |
create_thread_from_message(name, message, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None) async ¶
Creates a new news thread in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | 1-100 character thread name. | required |
message | Snowflake_Type | The message to connect this thread to. | required |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
reason | Absent[str] | The reason for creating this thread. | None |
Returns:
| Type | Description |
|---|---|
GuildNewsThread | The created public thread, if successful |
Source code in naff/models/discord/channel.py
1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 | |
GuildText ¶
Bases: GuildChannel, MessageableMixin, InvitableMixin, ThreadableMixin, WebhookMixin
Source code in naff/models/discord/channel.py
1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 | |
topic: Optional[str] = field(default=None) class-attribute ¶
The channel topic (0-1024 characters)
rate_limit_per_user: int = field(default=0) class-attribute ¶
Amount of seconds a user has to wait before sending another message (0-21600)
edit(name=MISSING, position=MISSING, permission_overwrites=MISSING, parent_id=MISSING, nsfw=MISSING, topic=MISSING, channel_type=MISSING, default_auto_archive_duration=MISSING, rate_limit_per_user=MISSING, reason=MISSING, **kwargs) async ¶
Edit the guild text channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
position | Absent[int] | the position of the channel in the left-hand listing | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | a list of PermissionOverwrite | MISSING |
parent_id | Absent[Snowflake_Type] | the parent category | MISSING |
nsfw | Absent[bool] | whether the channel is nsfw | MISSING |
topic | Absent[str] | 0-1024 character channel topic | MISSING |
channel_type | Absent[ChannelTypes] | the type of channel; only conversion between text and news is supported and only in guilds with the "NEWS" feature | MISSING |
default_auto_archive_duration | Absent[AutoArchiveDuration] | optional AutoArchiveDuration | MISSING |
rate_limit_per_user | Absent[int] | amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
reason | Absent[str] | An optional reason for the audit log | MISSING |
Returns:
| Type | Description |
|---|---|
Union[GuildText, GuildNews] | The edited channel. |
Source code in naff/models/discord/channel.py
1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 | |
create_public_thread(name, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None) async ¶
Creates a new public thread in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | 1-100 character thread name. | required |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
reason | Absent[str] | The reason for creating this thread. | None |
Returns:
| Type | Description |
|---|---|
GuildPublicThread | The created public thread, if successful |
Source code in naff/models/discord/channel.py
1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 | |
create_private_thread(name, invitable=MISSING, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None) async ¶
Creates a new private thread in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | 1-100 character thread name. | required |
invitable | Absent[bool] | whether non-moderators can add other non-moderators to a thread. | MISSING |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
reason | Absent[str] | The reason for creating this thread. | None |
Returns:
| Type | Description |
|---|---|
GuildPrivateThread | The created thread, if successful |
Source code in naff/models/discord/channel.py
1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 | |
create_thread_from_message(name, message, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None) async ¶
Creates a new public thread in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | 1-100 character thread name. | required |
message | Snowflake_Type | The message to connect this thread to. | required |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
reason | Absent[str] | The reason for creating this thread. | None |
Returns:
| Type | Description |
|---|---|
GuildPublicThread | The created public thread, if successful |
Source code in naff/models/discord/channel.py
1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 | |
ThreadChannel ¶
Bases: BaseChannel, MessageableMixin, WebhookMixin
Source code in naff/models/discord/channel.py
1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 | |
parent_id: Snowflake_Type = field(default=None, converter=optional_c(to_snowflake)) class-attribute ¶
id of the text channel this thread was created
owner_id: Snowflake_Type = field(default=None, converter=optional_c(to_snowflake)) class-attribute ¶
id of the creator of the thread
topic: Optional[str] = field(default=None) class-attribute ¶
The thread topic (0-1024 characters)
message_count: int = field(default=0) class-attribute ¶
An approximate count of messages in a thread, stops counting at 50
member_count: int = field(default=0) class-attribute ¶
An approximate count of users in a thread, stops counting at 50
archived: bool = field(default=False) class-attribute ¶
Whether the thread is archived
auto_archive_duration: int = field(default=attrs.Factory(lambda self: self.default_auto_archive_duration, takes_self=True)) class-attribute ¶
Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
locked: bool = field(default=False) class-attribute ¶
Whether the thread is locked
archive_timestamp: Optional[models.Timestamp] = field(default=None, converter=optional_c(timestamp_converter)) class-attribute ¶
Timestamp when the thread's archive status was last changed, used for calculating recent activity
create_timestamp: Optional[models.Timestamp] = field(default=None, converter=optional_c(timestamp_converter)) class-attribute ¶
Timestamp when the thread was created
flags: ChannelFlags = field(default=ChannelFlags.NONE, converter=ChannelFlags) class-attribute ¶
Flags for the thread
is_private() property ¶
Is this a private thread?
Source code in naff/models/discord/channel.py
1790 1791 1792 1793 | |
guild() property ¶
The guild this channel belongs to.
Source code in naff/models/discord/channel.py
1795 1796 1797 1798 | |
parent_channel() property ¶
The channel this thread is a child of.
Source code in naff/models/discord/channel.py
1800 1801 1802 1803 | |
parent_message() property ¶
The message this thread is a child of.
Source code in naff/models/discord/channel.py
1805 1806 1807 1808 | |
mention() property ¶
Returns a string that would mention this thread.
Source code in naff/models/discord/channel.py
1810 1811 1812 1813 | |
permission_overwrites() property ¶
The permission overwrites for this channel.
Source code in naff/models/discord/channel.py
1815 1816 1817 1818 | |
fetch_members() async ¶
Get the members that have access to this thread.
Source code in naff/models/discord/channel.py
1820 1821 1822 1823 | |
add_member(member) async ¶
Add a member to this thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member | Union[Member, Snowflake_Type] | The member to add | required |
Source code in naff/models/discord/channel.py
1825 1826 1827 1828 1829 1830 1831 1832 1833 | |
remove_member(member) async ¶
Remove a member from this thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
member | Union[Member, Snowflake_Type] | The member to remove | required |
Source code in naff/models/discord/channel.py
1835 1836 1837 1838 1839 1840 1841 1842 1843 | |
join() async ¶
Join this thread.
Source code in naff/models/discord/channel.py
1845 1846 1847 | |
leave() async ¶
Leave this thread.
Source code in naff/models/discord/channel.py
1849 1850 1851 | |
archive(locked=False, reason=MISSING) async ¶
Helper method to archive this thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locked | bool | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | False |
reason | Absent[str] | The reason for this archive | MISSING |
Returns:
| Type | Description |
|---|---|
TYPE_THREAD_CHANNEL | The archived thread channel object. |
Source code in naff/models/discord/channel.py
1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 | |
GuildNewsThread ¶
Bases: ThreadChannel
Source code in naff/models/discord/channel.py
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 | |
edit(name=MISSING, archived=MISSING, auto_archive_duration=MISSING, locked=MISSING, rate_limit_per_user=MISSING, reason=MISSING, **kwargs) async ¶
Edit this thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
archived | Absent[bool] | whether the thread is archived | MISSING |
auto_archive_duration | Absent[AutoArchiveDuration] | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | MISSING |
locked | Absent[bool] | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | MISSING |
rate_limit_per_user | Absent[int] | amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Returns:
| Type | Description |
|---|---|
GuildNewsThread | The edited thread channel object. |
Source code in naff/models/discord/channel.py
1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 | |
GuildPublicThread ¶
Bases: ThreadChannel
Source code in naff/models/discord/channel.py
1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 | |
edit(name=MISSING, archived=MISSING, auto_archive_duration=MISSING, applied_tags=MISSING, locked=MISSING, rate_limit_per_user=MISSING, flags=MISSING, reason=MISSING, **kwargs) async ¶
Edit this thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
archived | Absent[bool] | whether the thread is archived | MISSING |
applied_tags | Absent[List[Union[Snowflake_Type, ThreadTag]]] | list of tags to apply to a forum post (!!! This is for forum threads only) | MISSING |
auto_archive_duration | Absent[AutoArchiveDuration] | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | MISSING |
locked | Absent[bool] | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | MISSING |
rate_limit_per_user | Absent[int] | amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
flags | Absent[Union[int, ChannelFlags]] | channel flags for forum threads | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Returns:
| Type | Description |
|---|---|
GuildPublicThread | The edited thread channel object. |
Source code in naff/models/discord/channel.py
1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 | |
applied_tags() property ¶
The tags applied to this thread.
Note
This is only on forum threads.
Source code in naff/models/discord/channel.py
1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 | |
initial_post() property ¶
The initial message posted by the OP.
Note
This is only on forum threads.
Source code in naff/models/discord/channel.py
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 | |
GuildPrivateThread ¶
Bases: ThreadChannel
Source code in naff/models/discord/channel.py
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 | |
invitable: bool = field(default=False) class-attribute ¶
Whether non-moderators can add other non-moderators to a thread
edit(name=MISSING, archived=MISSING, auto_archive_duration=MISSING, locked=MISSING, rate_limit_per_user=MISSING, invitable=MISSING, reason=MISSING, **kwargs) async ¶
Edit this thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
archived | Absent[bool] | whether the thread is archived | MISSING |
auto_archive_duration | Absent[AutoArchiveDuration] | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | MISSING |
locked | Absent[bool] | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | MISSING |
rate_limit_per_user | Absent[int] | amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
invitable | Absent[bool] | whether non-moderators can add other non-moderators to a thread; only available on private threads | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Returns:
| Type | Description |
|---|---|
GuildPrivateThread | The edited thread channel object. |
Source code in naff/models/discord/channel.py
1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 | |
VoiceChannel ¶
Bases: GuildChannel
Source code in naff/models/discord/channel.py
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 | |
bitrate: int = field() class-attribute ¶
The bitrate (in bits) of the voice channel
user_limit: int = field() class-attribute ¶
The user limit of the voice channel
rtc_region: str = field(default='auto') class-attribute ¶
Voice region id for the voice channel, automatic when set to None
video_quality_mode: Union[VideoQualityModes, int] = field(default=VideoQualityModes.AUTO) class-attribute ¶
The camera video quality mode of the voice channel, 1 when not present
edit(name=MISSING, position=MISSING, permission_overwrites=MISSING, parent_id=MISSING, bitrate=MISSING, user_limit=MISSING, rtc_region=MISSING, video_quality_mode=MISSING, reason=MISSING, **kwargs) async ¶
Edit guild voice channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
position | Absent[int] | the position of the channel in the left-hand listing | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | a list of | MISSING |
parent_id | Absent[Snowflake_Type] | the parent category | MISSING |
bitrate | Absent[int] | the bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers) | MISSING |
user_limit | Absent[int] | the user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit | MISSING |
rtc_region | Absent[str] | channel voice region id, automatic when not set | MISSING |
video_quality_mode | Absent[VideoQualityModes] | the camera video quality mode of the voice channel | MISSING |
reason | Absent[str] | optional reason for audit logs | MISSING |
Returns:
| Type | Description |
|---|---|
Union[GuildVoice, GuildStageVoice] | The edited voice channel object. |
Source code in naff/models/discord/channel.py
2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 | |
members() property ¶
Returns a list of members that have access to this voice channel
Source code in naff/models/discord/channel.py
2087 2088 2089 2090 | |
voice_members() property ¶
Returns a list of members that are currently in the channel.
Note
This will not be accurate if the bot was offline while users joined the channel
Source code in naff/models/discord/channel.py
2092 2093 2094 2095 2096 2097 2098 2099 2100 | |
voice_state() property ¶
Returns the voice state of the bot in this channel if it is connected
Source code in naff/models/discord/channel.py
2102 2103 2104 2105 | |
connect(muted=False, deafened=False) async ¶
Connect the bot to this voice channel, or move the bot to this voice channel if it is already connected in another voice channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
muted | bool | Whether the bot should be muted when connected. | False |
deafened | bool | Whether the bot should be deafened when connected. | False |
Returns:
| Type | Description |
|---|---|
ActiveVoiceState | The new active voice state on successfully connection. |
Source code in naff/models/discord/channel.py
2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 | |
disconnect() async ¶
Disconnect from the currently connected voice state.
Raises:
| Type | Description |
|---|---|
VoiceNotConnected | if the bot is not connected to a voice channel |
Source code in naff/models/discord/channel.py
2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 | |
GuildStageVoice ¶
Bases: GuildVoice
Source code in naff/models/discord/channel.py
2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 | |
stage_instance: models.StageInstance = field(default=MISSING) class-attribute ¶
The stage instance that this voice channel belongs to
fetch_stage_instance() async ¶
Fetches the stage instance associated with this channel.
Returns:
| Type | Description |
|---|---|
StageInstance | The stage instance associated with this channel. If no stage is live, will return None. |
Source code in naff/models/discord/channel.py
2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 | |
create_stage_instance(topic, privacy_level=StagePrivacyLevel.GUILD_ONLY, reason=MISSING) async ¶
Create a stage instance in this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic | str | The topic of the stage (1-120 characters) | required |
privacy_level | StagePrivacyLevel | The privacy level of the stage | StagePrivacyLevel.GUILD_ONLY |
reason | Absent[Optional[str]] | The reason for creating this instance | MISSING |
Returns:
| Type | Description |
|---|---|
StageInstance | The created stage instance object. |
Source code in naff/models/discord/channel.py
2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 | |
close_stage(reason=MISSING) async ¶
Closes the live stage instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason | Absent[Optional[str]] | The reason for closing the stage | MISSING |
Source code in naff/models/discord/channel.py
2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 | |
GuildForum ¶
Bases: GuildChannel
Source code in naff/models/discord/channel.py
2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 | |
available_tags: List[ThreadTag] = field(factory=list) class-attribute ¶
A list of tags available to assign to threads
create_post(name, content, applied_tags=MISSING, *, auto_archive_duration=AutoArchiveDuration.ONE_DAY, rate_limit_per_user=MISSING, embeds=None, embed=None, components=None, stickers=None, allowed_mentions=None, files=None, file=None, tts=False, reason=MISSING) async ¶
Create a post within this channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the post | required |
content | str | None | The text content of this post | required |
applied_tags | Optional[List[Union[Snowflake_Type, ThreadTag]]] | A list of tag ids or tag objects to apply to this post | MISSING |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
rate_limit_per_user | Absent[int] | The time users must wait between sending messages | MISSING |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[List[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
files | Optional[Union[UPLOADABLE_TYPE, List[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
reason | Absent[str] | The reason for creating this post | MISSING |
Returns:
| Type | Description |
|---|---|
GuildPublicThread | A GuildPublicThread object representing the created post. |
Source code in naff/models/discord/channel.py
2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 | |
create_tag(name, emoji) async ¶
Create a tag for this forum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of the tag | required |
emoji | Union[PartialEmoji, dict, str] | The emoji to use for the tag | required |
Note
If the emoji is a custom emoji, it must be from the same guild as the channel.
Returns:
| Type | Description |
|---|---|
ThreadTag | The created tag object. |
Source code in naff/models/discord/channel.py
2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 | |
edit_tag(tag_id, *, name=None, emoji=None) async ¶
Edit a tag for this forum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag_id | Snowflake_Type | The id of the tag to edit | required |
name | str | None | The name for this tag | None |
emoji | Union[PartialEmoji, dict, str, None] | The emoji for this tag | None |
Source code in naff/models/discord/channel.py
2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 | |
delete_tag(tag_id) async ¶
Delete a tag for this forum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag_id | Snowflake_Type | The ID of the tag to delete | required |
Source code in naff/models/discord/channel.py
2339 2340 2341 2342 2343 2344 2345 2346 2347 | |
process_permission_overwrites(overwrites) ¶
Processes a permission overwrite lists into format for sending to discord.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overwrites | Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]] | The permission overwrites to process | required |
Returns:
| Type | Description |
|---|---|
List[dict] | The processed permission overwrites |
Source code in naff/models/discord/channel.py
2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 | |
Invite ¶
Bases: ClientObject
Source code in naff/models/discord/invite.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
code: str = field(repr=True) class-attribute ¶
the invite code (unique ID)
uses: int = field(default=0, repr=True) class-attribute ¶
the guild this invite is for
max_uses: int = field(default=0) class-attribute ¶
max number of times this invite can be used
max_age: int = field(default=0) class-attribute ¶
duration (in seconds) after which the invite expires
created_at: Timestamp = field(default=MISSING, converter=optional_c(timestamp_converter), repr=True) class-attribute ¶
when this invite was created
temporary: bool = field(default=False, repr=True) class-attribute ¶
whether this invite only grants temporary membership
target_type: Optional[Union[InviteTargetTypes, int]] = field(default=None, converter=optional_c(InviteTargetTypes), repr=True) class-attribute ¶
the type of target for this voice channel invite
approximate_presence_count: Optional[int] = field(default=MISSING) class-attribute ¶
approximate count of online members, returned from the GET /invites/<code> endpoint when with_counts is True
approximate_member_count: Optional[int] = field(default=MISSING) class-attribute ¶
approximate count of total members, returned from the GET /invites/<code> endpoint when with_counts is True
scheduled_event: Optional[Snowflake_Type] = field(default=None, converter=optional_c(to_snowflake), repr=True) class-attribute ¶
guild scheduled event data, only included if guild_scheduled_event_id contains a valid guild scheduled event id
expires_at: Optional[Timestamp] = field(default=None, converter=optional_c(timestamp_converter), repr=True) class-attribute ¶
the expiration date of this invite, returned from the GET /invites/<code> endpoint when with_expiration is True
stage_instance: Optional[StageInstance] = field(default=None) class-attribute ¶
stage instance data if there is a public Stage instance in the Stage channel this invite is for (deprecated)
target_application: Optional[dict] = field(default=None) class-attribute ¶
the embedded application to open for this voice channel embedded application invite
guild_preview: Optional[GuildPreview] = field(default=MISSING) class-attribute ¶
the guild this invite is for
channel() property ¶
The channel the invite is for.
Source code in naff/models/discord/invite.py
66 67 68 69 | |
inviter() property ¶
The user that created the invite or None.
Source code in naff/models/discord/invite.py
71 72 73 74 | |
target_user() property ¶
The user whose stream to display for this voice channel stream invite or None.
Source code in naff/models/discord/invite.py
76 77 78 79 | |
link() property ¶
The invite link.
Source code in naff/models/discord/invite.py
108 109 110 111 112 113 | |
delete(reason=MISSING) async ¶
Delete this invite.
Note
You must have the manage_channels permission on the channel this invite belongs to.
Note
With manage_guild permission, you can delete any invite across the guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason | Absent[str] | The reason for the deletion of invite. | MISSING |
Source code in naff/models/discord/invite.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
Role ¶
Bases: DiscordObject
Source code in naff/models/discord/role.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
fetch_bot() async ¶
Fetch the bot associated with this role if any.
Returns:
| Type | Description |
|---|---|
Member | None | Member object if any |
Source code in naff/models/discord/role.py
83 84 85 86 87 88 89 90 91 92 93 | |
get_bot() ¶
Get the bot associated with this role if any.
Returns:
| Type | Description |
|---|---|
Member | None | Member object if any |
Source code in naff/models/discord/role.py
95 96 97 98 99 100 101 102 103 104 105 | |
guild() property ¶
The guild object this role is from.
Source code in naff/models/discord/role.py
107 108 109 110 | |
default() property ¶
Is this the @everyone role.
Source code in naff/models/discord/role.py
112 113 114 115 | |
bot_managed() property ¶
Is this role owned/managed by a bot.
Source code in naff/models/discord/role.py
117 118 119 120 | |
mention() property ¶
Returns a string that would mention the role.
Source code in naff/models/discord/role.py
122 123 124 125 | |
integration() property ¶
Is this role owned/managed by an integration.
Source code in naff/models/discord/role.py
127 128 129 130 | |
members() property ¶
List of members with this role
Source code in naff/models/discord/role.py
132 133 134 135 | |
icon() property ¶
The icon of this role
Note
You have to use this method instead of the _icon attribute, because the first does account for unicode emojis
Source code in naff/models/discord/role.py
137 138 139 140 141 142 143 144 145 | |
is_assignable() property ¶
Can this role be assigned or removed by this bot?
Note
This does not account for permissions, only the role hierarchy
Source code in naff/models/discord/role.py
147 148 149 150 151 152 153 154 155 156 | |
delete(reason=MISSING) async ¶
Delete this role.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason | str | Missing | An optional reason for this deletion | MISSING |
Source code in naff/models/discord/role.py
158 159 160 161 162 163 164 165 166 | |
edit(name=None, permissions=None, color=None, hoist=None, mentionable=None) async ¶
Edit this role, all arguments are optional.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | None | name of the role | None |
permissions | str | None | New permissions to use | None |
color | Color | COLOR_TYPES | None | The color of the role | None |
hoist | bool | None | whether the role should be displayed separately in the sidebar | None |
mentionable | bool | None | whether the role should be mentionable | None |
Returns:
| Type | Description |
|---|---|
Role | Role with updated information |
Source code in naff/models/discord/role.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
PartialEmoji ¶
Bases: SnowflakeObject, DictSerializationMixin
Represent a basic ("partial") emoji used in discord.
Source code in naff/models/discord/emoji.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
id: Optional[Snowflake_Type] = field(repr=True, default=None, converter=optional(to_snowflake)) class-attribute ¶
The custom emoji id. Leave empty if you are using standard unicode emoji.
name: Optional[str] = field(repr=True, default=None) class-attribute ¶
The custom emoji name, or standard unicode emoji in string
animated: bool = field(repr=True, default=False) class-attribute ¶
Whether this emoji is animated
from_str(emoji_str) classmethod ¶
Generate a PartialEmoji from a discord Emoji string representation, or unicode emoji.
Handles
<:emoji_name:emoji_id> :emoji_name:emoji_id
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji_str | str | The string representation an emoji | required |
Returns:
| Type | Description |
|---|---|
PartialEmoji | A PartialEmoji object |
Raises:
| Type | Description |
|---|---|
ValueError | if the string cannot be parsed |
Source code in naff/models/discord/emoji.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
req_format() property ¶
Format used for web request.
Source code in naff/models/discord/emoji.py
82 83 84 85 86 87 88 | |
CustomEmoji ¶
Bases: PartialEmoji, ClientObject
Represent a custom emoji in a guild with all its properties.
Source code in naff/models/discord/emoji.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
require_colons: bool = field(default=False) class-attribute ¶
Whether this emoji must be wrapped in colons
managed: bool = field(default=False) class-attribute ¶
Whether this emoji is managed
available: bool = field(default=False) class-attribute ¶
Whether this emoji can be used, may be false due to loss of Server Boosts.
guild() property ¶
The guild this emoji belongs to.
Source code in naff/models/discord/emoji.py
123 124 125 126 | |
creator() property ¶
The member that created this emoji.
Source code in naff/models/discord/emoji.py
128 129 130 131 132 133 | |
roles() property ¶
The roles allowed to use this emoji.
Source code in naff/models/discord/emoji.py
135 136 137 138 | |
is_usable() property ¶
Determines if this emoji is usable by the current user.
Source code in naff/models/discord/emoji.py
140 141 142 143 144 145 146 147 | |
edit(name=None, roles=None, reason=None) async ¶
Modify the custom emoji information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Optional[str] | The name of the emoji. | None |
roles | Optional[List[Union[Snowflake_Type, Role]]] | The roles allowed to use this emoji. | None |
reason | Optional[str] | Attach a reason to this action, used for audit logs. | None |
Returns:
| Type | Description |
|---|---|
CustomEmoji | The newly modified custom emoji. |
Source code in naff/models/discord/emoji.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
delete(reason=None) async ¶
Deletes the custom emoji from the guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason | Optional[str] | Attach a reason to this action, used for audit logs. | None |
Source code in naff/models/discord/emoji.py
178 179 180 181 182 183 184 185 186 187 188 189 | |
process_emoji_req_format(emoji) ¶
Processes the emoji parameter into the str format required by the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji | Optional[Union[PartialEmoji, dict, str]] | The emoji to process. | required |
Returns:
| Type | Description |
|---|---|
Optional[str] | formatted string for discord |
Source code in naff/models/discord/emoji.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
process_emoji(emoji) ¶
Processes the emoji parameter into the dictionary format required by the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji | Optional[Union[PartialEmoji, dict, str]] | The emoji to process. | required |
Returns:
| Type | Description |
|---|---|
Optional[dict] | formatted dictionary for discord |
Source code in naff/models/discord/emoji.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
Message¶
Attachment ¶
Bases: DiscordObject
Source code in naff/models/discord/message.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
filename: str = field() class-attribute ¶
name of file attached
description: Optional[str] = field(default=None) class-attribute ¶
description for the file
content_type: Optional[str] = field(default=None) class-attribute ¶
the attachment's media type
size: int = field() class-attribute ¶
size of file in bytes
url: str = field() class-attribute ¶
source url of file
proxy_url: str = field() class-attribute ¶
a proxied url of file
height: Optional[int] = field(default=None) class-attribute ¶
height of file (if image)
width: Optional[int] = field(default=None) class-attribute ¶
width of file (if image)
ephemeral: bool = field(default=False) class-attribute ¶
whether this attachment is ephemeral
resolution() property ¶
Returns the image resolution of the attachment file
Source code in naff/models/discord/message.py
70 71 72 73 | |
ChannelMention ¶
Bases: DiscordObject
Source code in naff/models/discord/message.py
76 77 78 79 80 81 82 83 | |
MessageActivity dataclass ¶
Source code in naff/models/discord/message.py
86 87 88 89 90 91 | |
MessageReference ¶
Bases: DictSerializationMixin
Reference to an originating message.
Can be used for replies.
Source code in naff/models/discord/message.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
message_id: int = field(default=None, converter=optional_c(to_snowflake)) class-attribute ¶
id of the originating message.
channel_id: Optional[int] = field(default=None, converter=optional_c(to_snowflake)) class-attribute ¶
id of the originating message's channel.
guild_id: Optional[int] = field(default=None, converter=optional_c(to_snowflake)) class-attribute ¶
id of the originating message's guild.
fail_if_not_exists: bool = field(default=True) class-attribute ¶
When sending a message, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true.
for_message(message, fail_if_not_exists=True) classmethod ¶
Creates a reference to a message.
parameters message: The target message to reference. fail_if_not_exists: Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
Returns:
| Type | Description |
|---|---|
MessageReference | A MessageReference object. |
Source code in naff/models/discord/message.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
MessageInteraction ¶
Bases: DiscordObject
Source code in naff/models/discord/message.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
type: InteractionTypes = field(converter=InteractionTypes) class-attribute ¶
the type of interaction
name: str = field() class-attribute ¶
the name of the application command
user() async ¶
Get the user associated with this interaction.
Source code in naff/models/discord/message.py
148 149 150 | |
AllowedMentions ¶
Bases: DictSerializationMixin
The allowed mention field allows for more granular control over mentions without various hacks to the message content.
This will always validate against message content to avoid phantom pings, and check against user/bot permissions.
Source code in naff/models/discord/message.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
parse: Optional[List[str]] = field(factory=list) class-attribute ¶
An array of allowed mention types to parse from the content.
roles: Optional[List[Snowflake_Type]] = field(factory=list, converter=to_snowflake_list) class-attribute ¶
Array of role_ids to mention. (Max size of 100)
users: Optional[List[Snowflake_Type]] = field(factory=list, converter=to_snowflake_list) class-attribute ¶
Array of user_ids to mention. (Max size of 100)
replied_user = field(default=False) class-attribute ¶
For replies, whether to mention the author of the message being replied to. (default false)
add_parse(*mention_types) ¶
Add a mention type to the list of allowed mentions to parse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*mention_types | Union[MentionTypes, str] | The types of mentions to add | () |
Source code in naff/models/discord/message.py
172 173 174 175 176 177 178 179 180 181 182 183 | |
add_roles(*roles) ¶
Add roles that are allowed to be mentioned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*roles | Union[Role, Snowflake_Type] | The roles to add | () |
Source code in naff/models/discord/message.py
185 186 187 188 189 190 191 192 193 194 | |
add_users(*users) ¶
Add users that are allowed to be mentioned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*users | Union[Member, BaseUser, Snowflake_Type] | The users to add | () |
Source code in naff/models/discord/message.py
196 197 198 199 200 201 202 203 204 205 | |
all() classmethod ¶
Allows every user and role to be mentioned.
Returns:
| Type | Description |
|---|---|
AllowedMentions | An AllowedMentions object |
Source code in naff/models/discord/message.py
207 208 209 210 211 212 213 214 215 216 | |
none() classmethod ¶
Disallows any user or role to be mentioned.
Returns:
| Type | Description |
|---|---|
AllowedMentions | An AllowedMentions object |
Source code in naff/models/discord/message.py
218 219 220 221 222 223 224 225 226 227 | |
BaseMessage ¶
Bases: DiscordObject
Source code in naff/models/discord/message.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
guild() property ¶
The guild the message was sent in
Source code in naff/models/discord/message.py
237 238 239 240 | |
channel() property ¶
The channel the message was sent in
Source code in naff/models/discord/message.py
242 243 244 245 246 247 248 249 250 251 252 | |
thread() property ¶
The thread that was started from this message, includes thread member object
Source code in naff/models/discord/message.py
254 255 256 257 | |
author() property ¶
The author of this message. Only a valid user in the case where the message is generated by a user or bot user.
Source code in naff/models/discord/message.py
259 260 261 262 263 264 265 266 267 | |
Message ¶
Bases: BaseMessage
Source code in naff/models/discord/message.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | |
content: str = field(default=MISSING) class-attribute ¶
Contents of the message
timestamp: models.Timestamp = field(default=MISSING, converter=optional_c(timestamp_converter)) class-attribute ¶
When this message was sent
edited_timestamp: Optional[models.Timestamp] = field(default=None, converter=optional_c(timestamp_converter)) class-attribute ¶
When this message was edited (or None if never)
tts: bool = field(default=False) class-attribute ¶
Whether this was a TTS message
mention_everyone: bool = field(default=False) class-attribute ¶
Whether this message mentions everyone
mention_channels: List[ChannelMention] = field(factory=list) class-attribute ¶
Channels specifically mentioned in this message
attachments: List[Attachment] = field(factory=list) class-attribute ¶
Any attached files
embeds: List[models.Embed] = field(factory=list) class-attribute ¶
Any embedded content
reactions: List[models.Reaction] = field(factory=list) class-attribute ¶
Reactions to the message
nonce: Optional[Union[int, str]] = field(default=None) class-attribute ¶
Used for validating a message was sent
pinned: bool = field(default=False) class-attribute ¶
Whether this message is pinned
webhook_id: Optional[Snowflake_Type] = field(default=None, converter=to_optional_snowflake) class-attribute ¶
If the message is generated by a webhook, this is the webhook's id
type: MessageTypes = field(default=MISSING, converter=optional_c(MessageTypes)) class-attribute ¶
Type of message
activity: Optional[MessageActivity] = field(default=None, converter=optional_c(MessageActivity)) class-attribute ¶
Activity sent with Rich Presence-related chat embeds
application: Optional[models.Application] = field(default=None) class-attribute ¶
Application sent with Rich Presence-related chat embeds
application_id: Optional[Snowflake_Type] = field(default=None, converter=to_optional_snowflake) class-attribute ¶
If the message is an Interaction or application-owned webhook, this is the id of the application
message_reference: Optional[MessageReference] = field(default=None, converter=optional_c(MessageReference.from_dict)) class-attribute ¶
Data showing the source of a crosspost, channel follow add, pin, or reply message
flags: MessageFlags = field(default=MessageFlags.NONE, converter=MessageFlags) class-attribute ¶
Message flags combined as a bitfield
interaction: Optional[MessageInteraction] = field(default=None) class-attribute ¶
Sent if the message is a response to an Interaction
components: Optional[List[models.ActionRow]] = field(default=None) class-attribute ¶
Sent if the message contains components like buttons, action rows, or other interactive components
sticker_items: Optional[List[models.StickerItem]] = field(default=None) class-attribute ¶
Sent if the message contains stickers
mention_users() async property ¶
A generator of users mentioned in this message
Source code in naff/models/discord/message.py
320 321 322 323 324 | |
mention_roles() async property ¶
A generator of roles mentioned in this message
Source code in naff/models/discord/message.py
326 327 328 329 330 | |
thread() property ¶
The thread that was started from this message, if any
Source code in naff/models/discord/message.py
332 333 334 335 | |
fetch_referenced_message() async ¶
Fetch the message this message is referencing, if any.
Returns:
| Type | Description |
|---|---|
Optional[Message] | The referenced message, if found |
Source code in naff/models/discord/message.py
337 338 339 340 341 342 343 344 345 346 347 | |
get_referenced_message() ¶
Get the message this message is referencing, if any.
Returns:
| Type | Description |
|---|---|
Optional[Message] | The referenced message, if found |
Source code in naff/models/discord/message.py
349 350 351 352 353 354 355 356 357 358 359 | |
system_content() property ¶
Content for system messages. (boosts, welcomes, etc)
Source code in naff/models/discord/message.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
jump_url() property ¶
A url that allows the client to jump to this message.
Source code in naff/models/discord/message.py
494 495 496 497 | |
proto_url() property ¶
A URL like jump_url that uses protocols.
Source code in naff/models/discord/message.py
499 500 501 502 | |
edit(content=None, embeds=None, embed=None, components=None, allowed_mentions=None, attachments=None, files=None, file=None, tts=False, flags=None) async ¶
Edits the message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[Sequence[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[Sequence[Sequence[Union[BaseComponent, dict]]], Sequence[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
attachments | Optional[Optional[Sequence[Union[Attachment, dict]]]] | The attachments to keep, only used when editing message. | None |
files | Optional[Union[UPLOADABLE_TYPE, Sequence[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
Returns:
| Type | Description |
|---|---|
Message | New message object with edits applied |
Source code in naff/models/discord/message.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | |
delete(delay=MISSING) async ¶
Delete message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delay | Absent[Optional[int]] | Seconds to wait before deleting message. | MISSING |
Source code in naff/models/discord/message.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | |
reply(content=None, embeds=None, embed=None, **kwargs) async ¶
Reply to this message, takes all the same attributes as send.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
**kwargs | Mapping[str, Any] | Additional options to pass to | {} |
Returns:
| Type | Description |
|---|---|
Message | New message object. |
Source code in naff/models/discord/message.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | |
create_thread(name, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None) async ¶
Create a thread from this message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The name of this thread | required |
auto_archive_duration | Union[AutoArchiveDuration, int] | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | AutoArchiveDuration.ONE_DAY |
reason | Optional[str] | The optional reason for creating this thread | None |
Returns:
| Type | Description |
|---|---|
TYPE_THREAD_CHANNEL | The created thread object |
Raises:
| Type | Description |
|---|---|
ThreadOutsideOfGuild | if this is invoked on a message outside of a guild |
Source code in naff/models/discord/message.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
suppress_embeds() async ¶
Suppress embeds for this message.
Note
Requires the Permissions.MANAGE_MESSAGES permission.
Source code in naff/models/discord/message.py
637 638 639 640 641 642 643 644 645 646 647 648 649 | |
fetch_reaction(emoji, limit=MISSING, after=MISSING) async ¶
Fetches reactions of a specific emoji from this message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji | Union[PartialEmoji, dict, str] | The emoji to get | required |
limit | Absent[int] | Max number of users to return (1-100) | MISSING |
after | Absent[Snowflake_Type] | Get users after this user ID | MISSING |
Returns:
| Type | Description |
|---|---|
List[User] | list of users who have reacted with that emoji |
Source code in naff/models/discord/message.py
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
add_reaction(emoji) async ¶
Add a reaction to this message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji | Union[PartialEmoji, dict, str] | the emoji to react with | required |
Source code in naff/models/discord/message.py
674 675 676 677 678 679 680 681 682 683 | |
remove_reaction(emoji, member=MISSING) async ¶
Remove a specific reaction that a user reacted with.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji | Union[PartialEmoji, dict, str] | Emoji to remove | required |
member | Optional[Union[Member, User, Snowflake_Type]] | Member to remove reaction of. Default's to NAFF bot user. | MISSING |
Source code in naff/models/discord/message.py
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |
clear_reactions(emoji) async ¶
Clear a specific reaction from message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emoji | Union[PartialEmoji, dict, str] | The emoji to clear | required |
Source code in naff/models/discord/message.py
707 708 709 710 711 712 713 714 715 716 | |
clear_all_reactions() async ¶
Clear all emojis from a message.
Source code in naff/models/discord/message.py
718 719 720 | |
pin() async ¶
Pin message.
Source code in naff/models/discord/message.py
722 723 724 725 | |
unpin() async ¶
Unpin message.
Source code in naff/models/discord/message.py
727 728 729 730 | |
publish() async ¶
Publish this message.
(Discord api calls it "crosspost")
Source code in naff/models/discord/message.py
732 733 734 735 736 737 738 739 | |
MessageTypes ¶
Bases: CursedIntEnum
Types of message.
Source code in naff/models/discord/enums.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
process_allowed_mentions(allowed_mentions) ¶
Process allowed mentions into a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions object or dictionary | required |
Returns:
| Type | Description |
|---|---|
Optional[dict] | Dictionary of allowed mentions |
Raises:
| Type | Description |
|---|---|
ValueError | Invalid allowed mentions |
Source code in naff/models/discord/message.py
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | |
process_message_reference(message_reference) ¶
Process mention references into a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message_reference | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message reference object | required |
Returns:
| Type | Description |
|---|---|
Optional[dict] | Message reference dictionary |
Raises:
| Type | Description |
|---|---|
ValueError | Invalid message reference |
Source code in naff/models/discord/message.py
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 | |
process_message_payload(content=None, embeds=None, components=None, stickers=None, allowed_mentions=None, reply_to=None, attachments=None, tts=False, flags=None, **kwargs) ¶
Format message content for it to be ready to send discord.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[List[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
reply_to | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message to reference, must be from the same channel. | None |
attachments | Optional[List[Union[Attachment, dict]]] | The attachments to keep, only used when editing message. | None |
tts | bool | Should this message use Text To Speech. | False |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
Returns:
| Type | Description |
|---|---|
dict | Dictionary |
Source code in naff/models/discord/message.py
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 | |
ReactionUsers ¶
Bases: AsyncIterator
An async iterator for searching through a channel's history.
Attributes:
| Name | Type | Description |
|---|---|---|
reaction | Reaction | The reaction to search through |
limit | Reaction | The maximum number of users to return (set to 0 for no limit) |
after | Snowflake_Type | get users after this message ID |
Source code in naff/models/discord/reaction.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
fetch() async ¶
Gets all the users who reacted to the message. Requests user data from discord API if not cached.
Returns:
| Type | Description |
|---|---|
List[User] | A list of users who reacted to the message. |
Source code in naff/models/discord/reaction.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
Reaction ¶
Bases: ClientObject
Source code in naff/models/discord/reaction.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
count: int = field() class-attribute ¶
times this emoji has been used to react
me: bool = field(default=False) class-attribute ¶
whether the current user reacted using this emoji
emoji: PartialEmoji = field(converter=PartialEmoji.from_dict) class-attribute ¶
emoji information
users(limit=0, after=None) ¶
Users who reacted using this emoji.
Source code in naff/models/discord/reaction.py
79 80 81 | |
message() property ¶
The message this reaction is on.
Source code in naff/models/discord/reaction.py
83 84 85 86 | |
channel() property ¶
The channel this reaction is on.
Source code in naff/models/discord/reaction.py
88 89 90 91 | |
remove() async ¶
Remove all this emoji's reactions from the message.
Source code in naff/models/discord/reaction.py
93 94 95 | |
UX.¶
EmbedField ¶
Bases: DictSerializationMixin
Representation of an embed field.
Attributes:
| Name | Type | Description |
|---|---|---|
name | str | Field name |
value | str | Field value |
inline | bool | If the field should be inline |
Source code in naff/models/discord/embed.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
EmbedAuthor ¶
Bases: DictSerializationMixin
Representation of an embed author.
Attributes:
| Name | Type | Description |
|---|---|---|
name | Optional[str] | Name to show on embed |
url | Optional[str] | Url to go to when name is clicked |
icon_url | Optional[str] | Icon to show next to name |
proxy_icon_url | Optional[str] | Proxy icon url |
Source code in naff/models/discord/embed.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
EmbedAttachment ¶
Bases: DictSerializationMixin
Representation of an attachment.
Attributes:
| Name | Type | Description |
|---|---|---|
url | Optional[str] | Attachment url |
proxy_url | Optional[str] | Proxy url |
height | Optional[int] | Attachment height |
width | Optional[int] | Attachment width |
Source code in naff/models/discord/embed.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
EmbedFooter ¶
Bases: DictSerializationMixin
Representation of an Embed Footer.
Attributes:
| Name | Type | Description |
|---|---|---|
text | str | Footer text |
icon_url | Optional[str] | Footer icon url |
proxy_icon_url | Optional[str] | Proxy icon url |
Source code in naff/models/discord/embed.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
converter(ingest) classmethod ¶
A converter to handle users passing raw strings or dictionaries as footers to the Embed object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ingest | Union[dict, str, EmbedFooter] | The data to convert | required |
Returns:
| Type | Description |
|---|---|
EmbedFooter | An EmbedFooter object |
Source code in naff/models/discord/embed.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
EmbedProvider ¶
Bases: DictSerializationMixin
Represents an embed's provider.
Note
Only used by system embeds, not bots
Attributes:
| Name | Type | Description |
|---|---|---|
name | Optional[str] | Provider name |
url | Optional[str] | Provider url |
Source code in naff/models/discord/embed.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
Embed ¶
Bases: DictSerializationMixin
Represents a discord embed object.
Source code in naff/models/discord/embed.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
title: Optional[str] = field(default=None, repr=True) class-attribute ¶
The title of the embed
description: Optional[str] = field(default=None, repr=True) class-attribute ¶
The description of the embed
color: Optional[Union[Color, dict, tuple, list, str, int]] = field(default=None, repr=True, metadata=export_converter(process_color)) class-attribute ¶
The colour of the embed
url: Optional[str] = field(default=None, validator=v_optional(instance_of(str)), repr=True) class-attribute ¶
The url the embed should direct to when clicked
timestamp: Optional[Timestamp] = field(default=None, converter=c_optional(timestamp_converter), validator=v_optional(instance_of((datetime, float, int))), repr=True) class-attribute ¶
Timestamp of embed content
fields: List[EmbedField] = field(factory=list, converter=EmbedField.from_list, repr=True) class-attribute ¶
A list of fields to go in the embed
author: Optional[EmbedAuthor] = field(default=None, converter=c_optional(EmbedAuthor.from_dict)) class-attribute ¶
The author of the embed
thumbnail: Optional[EmbedAttachment] = field(default=None, converter=c_optional(EmbedAttachment.from_dict)) class-attribute ¶
The thumbnail of the embed
image: Optional[EmbedAttachment] = field(default=None, converter=c_optional(EmbedAttachment.from_dict)) class-attribute ¶
The image of the embed
video: Optional[EmbedAttachment] = field(default=None, converter=c_optional(EmbedAttachment.from_dict), metadata=no_export_meta) class-attribute ¶
The video of the embed, only used by system embeds
footer: Optional[EmbedFooter] = field(default=None, converter=c_optional(EmbedFooter.converter)) class-attribute ¶
The footer of the embed
provider: Optional[EmbedProvider] = field(default=None, converter=c_optional(EmbedProvider.from_dict), metadata=no_export_meta) class-attribute ¶
The provider of the embed, only used for system embeds
set_author(name, url=None, icon_url=None) ¶
Set the author field of the embed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The text to go in the title section | required |
url | Optional[str] | A url link to the author | None |
icon_url | Optional[str] | A url of an image to use as the icon | None |
Source code in naff/models/discord/embed.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
set_thumbnail(url) ¶
Set the thumbnail of the embed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url | str | the url of the image to use | required |
Source code in naff/models/discord/embed.py
300 301 302 303 304 305 306 307 308 | |
set_image(url) ¶
Set the image of the embed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url | str | the url of the image to use | required |
Source code in naff/models/discord/embed.py
310 311 312 313 314 315 316 317 318 | |
set_footer(text, icon_url=None) ¶
Set the footer field of the embed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text | str | The text to go in the title section | required |
icon_url | Optional[str] | A url of an image to use as the icon | None |
Source code in naff/models/discord/embed.py
320 321 322 323 324 325 326 327 328 329 | |
add_field(name, value, inline=False) ¶
Add a field to the embed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The title of this field | required |
value | Any | The value in this field | required |
inline | bool | Should this field be inline with other fields? | False |
Source code in naff/models/discord/embed.py
331 332 333 334 335 336 337 338 339 340 341 342 | |
process_embeds(embeds) ¶
Process the passed embeds into a format discord will understand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
embeds | Optional[Union[List[Union[Embed, Dict]], Union[Embed, Dict]]] | List of dict / embeds to process | required |
Returns:
| Type | Description |
|---|---|
Optional[List[dict]] | formatted list for discord |
Source code in naff/models/discord/embed.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
Asset ¶
Represents a discord asset.
Attributes:
| Name | Type | Description |
|---|---|---|
BASE | str | The |
url | str | The URL of this asset |
hash | Optional[str] | The hash of this asset |
Source code in naff/models/discord/asset.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
from_path_hash(client, path, asset_hash) classmethod ¶
Create an asset from a path and asset's hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client | Client | The NAFF bot instance | required |
path | str | The CDN Endpoints for the type of asset. | required |
asset_hash | str | The hash representation of the target asset. | required |
Returns:
| Type | Description |
|---|---|
Asset | A new Asset object |
Source code in naff/models/discord/asset.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
url() property ¶
The URL of this asset.
Source code in naff/models/discord/asset.py
49 50 51 52 53 | |
as_url(*, extension=None, size=4096) ¶
Get the url of this asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extension | str | None | The extension to override the assets default with | None |
size | int | The size of asset to return | 4096 |
Returns:
| Type | Description |
|---|---|
str | A url for this asset with the given parameters |
Source code in naff/models/discord/asset.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
animated() property ¶
True if this asset is animated.
Source code in naff/models/discord/asset.py
73 74 75 76 | |
fetch(extension=None, size=None) async ¶
Fetch the asset from the Discord CDN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extension | Optional[str] | File extension based on the target image format | None |
size | Optional[int] | The image size, can be any power of two between 16 and 4096. | None |
Returns:
| Type | Description |
|---|---|
bytes | Raw byte array of the file |
Raises:
| Type | Description |
|---|---|
ValueError | Incorrect file size if not power of 2 between 16 and 4096 |
Source code in naff/models/discord/asset.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
save(fd, extension=None, size=None) async ¶
Save the asset to a local file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fd | Union[str, bytes, PathLike, int] | Destination path to save the file to. | required |
extension | Optional[str] | File extension based on the target image format. | None |
size | Optional[int] | The image size, can be any power of two between 16 and 4096. | None |
Returns:
| Type | Description |
|---|---|
int | Status code result of file write |
Source code in naff/models/discord/asset.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
Color ¶
Source code in naff/models/discord/color.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
value: int = field(repr=True) class-attribute ¶
The color value as an integer.
clamp(x, min_value=0, max_value=255) staticmethod ¶
Sanitise a value between a minimum and maximum value
Source code in naff/models/discord/color.py
54 55 56 57 | |
from_rgb(r, g, b) classmethod ¶
Create a Color object from red, green and blue values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r | int | The red value. | required |
g | int | The green value. | required |
b | int | The blue value. | required |
Returns:
| Type | Description |
|---|---|
Color | A Color object. |
Source code in naff/models/discord/color.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
from_hex(value) classmethod ¶
Create a Color object from a hexadecimal string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value | str | The hexadecimal string. | required |
Returns:
| Type | Description |
|---|---|
Color | A Color object. |
Source code in naff/models/discord/color.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
from_hsv(h, s, v) classmethod ¶
Create a Color object from a hue, saturation and value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h | int | The hue value. | required |
s | int | The saturation value. | required |
v | int | The value value. | required |
Returns:
| Type | Description |
|---|---|
Color | A Color object. |
Source code in naff/models/discord/color.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
random() classmethod ¶
Returns random Color instance
Source code in naff/models/discord/color.py
111 112 113 114 115 | |
r() property ¶
Red color value
Source code in naff/models/discord/color.py
132 133 134 135 | |
g() property ¶
Green color value
Source code in naff/models/discord/color.py
137 138 139 140 | |
b() property ¶
Blue color value
Source code in naff/models/discord/color.py
142 143 144 145 | |
rgb() writable property ¶
The red, green, blue color values in a tuple
Source code in naff/models/discord/color.py
147 148 149 150 | |
rgb_float() property ¶
The red, green, blue color values in a tuple
Source code in naff/models/discord/color.py
159 160 161 162 163 | |
hex() writable property ¶
Hexadecimal representation of color value
Source code in naff/models/discord/color.py
165 166 167 168 169 | |
hsv() writable property ¶
The hue, saturation, value color values in a tuple
Source code in naff/models/discord/color.py
178 179 180 181 | |
BrandColors ¶
Bases: Color, Enum
A collection of colors complying to the Discord Brand specification.
https://discord.com/branding
Source code in naff/models/discord/color.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
MaterialColors ¶
Bases: Color, Enum
A collection of material ui colors.
https://www.materialpalette.com/
Source code in naff/models/discord/color.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
FlatUIColors ¶
Bases: Color, Enum
A collection of flat ui colours.
https://materialui.co/flatuicolors
Source code in naff/models/discord/color.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
RoleColors ¶
Bases: Color, Enum
A collection of the default role colors Discord provides.
Source code in naff/models/discord/color.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
process_color(color) ¶
Process color to a format that can be used by discord.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color | Color | dict | COLOR_TYPES | None | The color to process. | required |
Returns:
| Type | Description |
|---|---|
int | None | The processed color value. |
Source code in naff/models/discord/color.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
File ¶
Representation of a file.
Used for sending files to discord.
Source code in naff/models/discord/file.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
file: Union[IOBase, BinaryIO, Path, str] = field(repr=True) class-attribute ¶
Location of file to send or the bytes.
file_name: Optional[str] = field(repr=True, default=None) class-attribute ¶
Set a filename that will be displayed when uploaded to discord. If you leave this empty, the file will be called file by default
open_file() ¶
Opens the file.
Returns:
| Type | Description |
|---|---|
BinaryIO | A file-like BinaryIO object. |
Source code in naff/models/discord/file.py
24 25 26 27 28 29 30 31 32 33 34 35 | |
open_file(file) ¶
Opens the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file | UPLOADABLE_TYPE | The target file or path to file. | required |
Returns:
| Type | Description |
|---|---|
BinaryIO | A file-like BinaryIO object. |
Source code in naff/models/discord/file.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
Commands¶
BaseCommand ¶
Bases: DictSerializationMixin, CallbackObject
An object all commands inherit from. Outlines the basic structure of a command, and handles checks.
Attributes:
| Name | Type | Description |
|---|---|---|
extension | Any | The extension this command belongs to. |
enabled | bool | Whether this command is enabled |
checks | list | Any checks that must be run before this command can be run |
callback | Callable[..., Coroutine] | The coroutine to be called for this command |
error_callback | Callable[..., Coroutine] | The coroutine to be called when an error occurs |
pre_run_callback | Callable[..., Coroutine] | A coroutine to be called before this command is run but after the checks |
post_run_callback | Callable[..., Coroutine] | A coroutine to be called after this command has run |
Source code in naff/models/naff/command.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
error(call) ¶
A decorator to declare a coroutine as one that will be run upon an error.
Source code in naff/models/naff/command.py
278 279 280 281 282 283 | |
pre_run(call) ¶
A decorator to declare a coroutine as one that will be run before the command.
Source code in naff/models/naff/command.py
285 286 287 288 289 290 | |
post_run(call) ¶
A decorator to declare a coroutine as one that will be run after the command has.
Source code in naff/models/naff/command.py
292 293 294 295 296 297 | |
check(check) ¶
Add a check to a command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check | Callable[[Context], Awaitable[bool]] | A coroutine as a check for this command | required |
Source code in naff/models/naff/command.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
cooldown(bucket, rate, interval) ¶
Add a cooldown to a command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket | Buckets | The bucket used to track cooldowns | required |
rate | int | How many commands may be ran per interval | required |
interval | float | How many seconds to wait for a cooldown | required |
Source code in naff/models/naff/command.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
max_concurrency(bucket, concurrent) ¶
Add a maximum number of concurrent instances to the command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket | Buckets | The bucket to enforce the maximum within | required |
concurrent | int | The maximum number of concurrent instances to allow | required |
Source code in naff/models/naff/command.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
A decorator to declare a coroutine as a prefixed command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | Optional[str] | The name of the command. Defaults to the name of the coroutine. | None |
aliases | Optional[list[str]] | The list of aliases the command can be invoked under. | None |
help | Optional[str] | The long help text for the command. Defaults to the docstring of the coroutine, if there is one. | None |
brief | Optional[str] | The short help text for the command. Defaults to the first line of the help text, if there is one. | None |
usage | Optional[str] | A string displaying how the command can be used. If no string is set, it will default to the command's signature. Useful for help commands. | None |
enabled | bool | Whether this command can be run at all. | True |
hidden | bool | If | False |
ignore_extra | bool | If | True |
hierarchical_checking | bool | If | True |
Source code in naff/models/naff/prefixed_commands.py
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | |
Application Commands¶
BaseComponent ¶
Bases: DictSerializationMixin
A base component class.
Warning
This should never be instantiated.
Source code in naff/models/discord/components.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
InteractiveComponent ¶
Bases: BaseComponent
A base interactive component class.
Warning
This should never be instantiated.
Source code in naff/models/discord/components.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
Button ¶
Bases: InteractiveComponent
Represents a discord ui button.
Attributes:
| Name | Type | Description |
|---|---|---|
style | optional[ButtonStyles, int] | Buttons come in a variety of styles to convey different types of actions. |
label | optional[str] | The text that appears on the button, max 80 characters. |
emoji | optional[Union[PartialEmoji, dict, str]] | The emoji that appears on the button. |
custom_id | Optional[str] | A developer-defined identifier for the button, max 100 characters. |
url | Optional[str] | A url for link-style buttons. |
disabled | bool | Disable the button and make it not interactable, default false. |
Source code in naff/models/discord/components.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
SelectOption ¶
Bases: BaseComponent
Represents a select option.
Attributes:
| Name | Type | Description |
|---|---|---|
label | str | The label (max 80 characters) |
value | str | The value of the select, this is whats sent to your bot |
description | Optional[str] | A description of this option |
emoji | Optional[Union[PartialEmoji, dict, str] | An emoji to show in this select option |
default | bool | Is this option selected by default |
Source code in naff/models/discord/components.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
Select ¶
Bases: InteractiveComponent
Represents a select component.
Attributes:
| Name | Type | Description |
|---|---|---|
options | List[dict] | The choices in the select, max 25. |
custom_id | str | A developer-defined identifier for the button, max 100 characters. |
placeholder | str | The custom placeholder text to show if nothing is selected, max 100 characters. |
min_values | Optional[int] | The minimum number of items that must be chosen. (default 1, min 0, max 25) |
max_values | Optional[int] | The maximum number of items that can be chosen. (default 1, max 25) |
disabled | bool | Disable the select and make it not intractable, default false. |
type | Union[ComponentTypes, int] | The action role type number defined by discord. This cannot be modified. |
Source code in naff/models/discord/components.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
ActionRow ¶
Bases: BaseComponent
Represents an action row.
Attributes:
| Name | Type | Description |
|---|---|---|
components | List[Union[dict, Select, Button]] | The components within this action row |
type | Union[ComponentTypes, int] | The action role type number defined by discord. This cannot be modified. |
Source code in naff/models/discord/components.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
add_components(*components) ¶
Add one or more component(s) to this action row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*components | Union[dict, Button, Select] | The components to add | () |
Source code in naff/models/discord/components.py
276 277 278 279 280 281 282 283 284 | |
process_components(components) ¶
Process the passed components into a format discord will understand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components | Optional[Union[List[List[Union[BaseComponent, Dict]]], List[Union[BaseComponent, Dict]], BaseComponent, Dict]] | List of dict / components to process | required |
Returns:
| Type | Description |
|---|---|
List[Dict] | formatted dictionary for discord |
Raises:
| Type | Description |
|---|---|
ValueError | Invalid components |
Source code in naff/models/discord/components.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
spread_to_rows(*components, max_in_row=5) ¶
A helper function that spreads your components into ActionRows of a set size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*components | Union[ActionRow, Button, Select] | The components to spread, use | () |
max_in_row | int | The maximum number of components in each row | 5 |
Returns:
| Type | Description |
|---|---|
List[ActionRow] | List[ActionRow] of components spread to rows |
Raises:
| Type | Description |
|---|---|
ValueError | Too many or few components or rows |
Source code in naff/models/discord/components.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
get_components_ids(component) ¶
Creates a generator with the custom_id of a component or list of components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component | Union[str, dict, list, InteractiveComponent] | Objects to get | required |
Returns:
| Type | Description |
|---|---|
Iterator[str] | Generator with the |
Raises:
| Type | Description |
|---|---|
ValueError | Unknown component type |
Source code in naff/models/discord/components.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
InputText ¶
Bases: InteractiveComponent
An input component for modals
Source code in naff/models/discord/modal.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
label: str = field(validator=str_validator) class-attribute ¶
the label for this component
style: Union[TextStyles, int] = field() class-attribute ¶
the Text Input Style for single or multiple lines input
custom_id: Optional[str] = field(factory=lambda : str(uuid.uuid4()), validator=str_validator) class-attribute ¶
a developer-defined identifier for the input, max 100 characters
placeholder: Optional[str] = field(default=MISSING, validator=str_validator, kw_only=True) class-attribute ¶
custom placeholder text if the input is empty, max 100 characters
value: Optional[str] = field(default=MISSING, validator=str_validator, kw_only=True) class-attribute ¶
a pre-filled value for this component, max 4000 characters
required: bool = field(default=True, kw_only=True) class-attribute ¶
whether this component is required to be filled, default true
min_length: Optional[int] = field(default=MISSING, kw_only=True) class-attribute ¶
the minimum input length for a text input, min 0, max 4000
max_length: Optional[int] = field(default=MISSING, kw_only=True) class-attribute ¶
the maximum input length for a text input, min 1, max 4000. Must be more than min_length.
ShortText ¶
Bases: InputText
A single line input component for modals
Source code in naff/models/discord/modal.py
50 51 52 53 54 | |
ParagraphText ¶
Bases: InputText
A multi line input component for modals
Source code in naff/models/discord/modal.py
57 58 59 60 61 | |
Modal ¶
Bases: DictSerializationMixin
Form submission style component on discord
Source code in naff/models/discord/modal.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
title: str = field(validator=str_validator) class-attribute ¶
the title of the popup modal, max 45 characters
components: List[InputText] = field() class-attribute ¶
between 1 and 5 (inclusive) components that make up the modal
custom_id: Optional[str] = field(factory=lambda : str(uuid.uuid4()), validator=str_validator) class-attribute ¶
a developer-defined identifier for the component, max 100 characters
LocalisedName ¶
Bases: LocalisedField
A localisation object for names.
Source code in naff/models/naff/application_commands.py
78 79 80 81 82 83 | |
LocalisedDesc ¶
Bases: LocalisedField
A localisation object for descriptions.
Source code in naff/models/naff/application_commands.py
86 87 88 89 90 91 | |
OptionTypes ¶
Bases: IntEnum
Option types supported by slash commands.
Source code in naff/models/naff/application_commands.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
from_type(t) classmethod ¶
Convert data types to their corresponding OptionType.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t | type | The datatype to convert | required |
Returns:
| Type | Description |
|---|---|
OptionTypes | OptionType or None |
Source code in naff/models/naff/application_commands.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
CallbackTypes ¶
Bases: IntEnum
Types of callback supported by interaction response.
Source code in naff/models/naff/application_commands.py
141 142 143 144 145 146 147 148 149 150 | |
InteractionCommand ¶
Bases: BaseCommand
Represents a discord abstract interaction command.
Attributes:
| Name | Type | Description |
|---|---|---|
scope | Denotes whether its global or for specific guild. | |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. |
dm_permission | bool | Should this command be available in DMs. |
cmd_id | Dict[str, Snowflake_Type] | The id of this command given by discord. |
callback | Callable[..., Coroutine] | The coroutine to callback when this interaction is received. |
Source code in naff/models/naff/application_commands.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
mention(scope=None) ¶
Returns a string that would mention the interaction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope | Optional[Snowflake_Type] | If the command is available in multiple scope, specify which scope to get the mention for. Defaults to the first available one if not specified. | None |
Returns:
| Type | Description |
|---|---|
str | The markdown mention. |
Source code in naff/models/naff/application_commands.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
resolved_name() property ¶
A representation of this interaction's name.
Source code in naff/models/naff/application_commands.py
226 227 228 229 | |
ContextMenu ¶
Bases: InteractionCommand
Represents a discord context menu.
Attributes:
| Name | Type | Description |
|---|---|---|
name | LocalisedField | The name of this entry. |
type | CommandTypes | The type of entry (user or message). |
Source code in naff/models/naff/application_commands.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
SlashCommandChoice ¶
Bases: DictSerializationMixin
Represents a discord slash command choice.
Attributes:
| Name | Type | Description |
|---|---|---|
name | LocalisedField | The name the user will see |
value | Union[str, int, float] | The data sent to your code when this choice is used |
Source code in naff/models/naff/application_commands.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
SlashCommandOption ¶
Bases: DictSerializationMixin
Represents a discord slash command option.
Attributes:
| Name | Type | Description |
|---|---|---|
name | LocalisedName | The name of this option |
type | Union[OptionTypes, int] | The type of option |
description | LocalisedDesc | The description of this option |
required | bool | "This option must be filled to use the command" |
choices | List[Union[SlashCommandChoice, Dict]] | A list of choices the user has to pick between |
channel_types | Optional[list[Union[ChannelTypes, int]]] | The channel types permitted. The option needs to be a channel |
min_value | Optional[float] | The minimum value permitted. The option needs to be an integer or float |
max_value | Optional[float] | The maximum value permitted. The option needs to be an integer or float |
min_length | Optional[int] | The minimum length of text a user can input. The option needs to be a string |
max_length | Optional[int] | The maximum length of text a user can input. The option needs to be a string |
Source code in naff/models/naff/application_commands.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
SlashCommand ¶
Bases: InteractionCommand
Source code in naff/models/naff/application_commands.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
autocomplete(option_name) ¶
A decorator to declare a coroutine as an option autocomplete.
Source code in naff/models/naff/application_commands.py
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
slash_command(name, *, description=MISSING, scopes=MISSING, options=None, default_member_permissions=None, dm_permission=True, sub_cmd_name=None, group_name=None, sub_cmd_description='No Description Set', group_description='No Description Set', nsfw=False) ¶
A decorator to declare a coroutine as a slash command.
Note
While the base and group descriptions arent visible in the discord client, currently. We strongly advise defining them anyway, if you're using subcommands, as Discord has said they will be visible in one of the future ui updates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | LocalisedName | 1-32 character name of the command | required |
description | Absent[str | LocalisedDesc] | 1-100 character description of the command | MISSING |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
options | Optional[List[Union[SlashCommandOption, Dict]]] | The parameters for the command, max 25 | None |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
dm_permission | bool | Should this command be available in DMs. | True |
sub_cmd_name | str | LocalisedName | 1-32 character name of the subcommand | None |
sub_cmd_description | str | LocalisedDesc | 1-100 character description of the subcommand | 'No Description Set' |
group_name | str | LocalisedName | 1-32 character name of the group | None |
group_description | str | LocalisedDesc | 1-100 character description of the group | 'No Description Set' |
nsfw | bool | This command should only work in NSFW channels | False |
Returns:
| Type | Description |
|---|---|
Callable[[Callable[..., Coroutine]], SlashCommand] | SlashCommand Object |
Source code in naff/models/naff/application_commands.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 | |
subcommand(base, *, subcommand_group=None, name=None, description=MISSING, base_description=None, base_desc=None, base_default_member_permissions=None, base_dm_permission=True, subcommand_group_description=None, sub_group_desc=None, scopes=None, options=None, nsfw=False) ¶
A decorator specifically tailored for creating subcommands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base | str | LocalisedName | The name of the base command | required |
subcommand_group | Optional[str | LocalisedName] | The name of the subcommand group, if any. | None |
name | Optional[str | LocalisedName] | The name of the subcommand, defaults to the name of the coroutine. | None |
description | Absent[str | LocalisedDesc] | The description of the subcommand | MISSING |
base_description | Optional[str | LocalisedDesc] | The description of the base command | None |
base_desc | Optional[str | LocalisedDesc] | An alias of | None |
base_default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
base_dm_permission | bool | Should this command be available in DMs. | True |
subcommand_group_description | Optional[str | LocalisedDesc] | Description of the subcommand group | None |
sub_group_desc | Optional[str | LocalisedDesc] | An alias for | None |
scopes | List[Snowflake_Type] | The scopes of which this command is available, defaults to GLOBAL_SCOPE | None |
options | List[dict] | The options for this command | None |
nsfw | bool | This command should only work in NSFW channels | False |
Returns:
| Type | Description |
|---|---|
Callable[[Coroutine], SlashCommand] | A SlashCommand object |
Source code in naff/models/naff/application_commands.py
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | |
context_menu(name, context_type, scopes=MISSING, default_member_permissions=None, dm_permission=True) ¶
A decorator to declare a coroutine as a Context Menu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | LocalisedName | 1-32 character name of the context menu | required |
context_type | CommandTypes | The type of context menu | required |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
dm_permission | bool | Should this command be available in DMs. | True |
Returns:
| Type | Description |
|---|---|
Callable[[Coroutine], ContextMenu] | ContextMenu object |
Source code in naff/models/naff/application_commands.py
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | |
component_callback(*custom_id) ¶
Register a coroutine as a component callback.
Component callbacks work the same way as commands, just using components as a way of invoking, instead of messages. Your callback will be given a single argument, ComponentContext
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*custom_id | str | The custom ID of the component to wait for | () |
Source code in naff/models/naff/application_commands.py
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | |
modal_callback(*custom_id) ¶
Register a coroutine as a modal callback.
Modal callbacks work the same way as commands, just using modals as a way of invoking, instead of messages. Your callback will be given a single argument, ModalContext
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*custom_id | str | The custom ID of the modal to wait for | () |
Source code in naff/models/naff/application_commands.py
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 | |
slash_option(name, description, opt_type, required=False, autocomplete=False, choices=None, channel_types=None, min_value=None, max_value=None, min_length=None, max_length=None) ¶
A decorator to add an option to a slash command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | 1-32 lowercase character name matching ^[\w-]{1,32}$ | required |
opt_type | Union[OptionTypes, int] | The type of option | required |
description | str | 1-100 character description of option | required |
required | bool | If the parameter is required or optional--default false | False |
choices | List[Union[SlashCommandChoice, dict]] | A list of choices the user has to pick between (max 25) | None |
channel_types | Optional[list[Union[ChannelTypes, int]]] | The channel types permitted. The option needs to be a channel | None |
min_value | Optional[float] | The minimum value permitted. The option needs to be an integer or float | None |
max_value | Optional[float] | The maximum value permitted. The option needs to be an integer or float | None |
min_length | Optional[int] | The minimum length of text a user can input. The option needs to be a string | None |
max_length | Optional[int] | The maximum length of text a user can input. The option needs to be a string | None |
Source code in naff/models/naff/application_commands.py
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 | |
slash_default_member_permission(permission) ¶
A decorator to permissions members need to have by default to use a command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
permission | Permissions | The permissions to require for to this command | required |
Source code in naff/models/naff/application_commands.py
895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | |
auto_defer(ephemeral=False, time_until_defer=0.0) ¶
A decorator to add an auto defer to a application command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ephemeral | bool | Should the command be deferred as ephemeral | False |
time_until_defer | float | How long to wait before deferring automatically | 0.0 |
Source code in naff/models/naff/application_commands.py
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | |
application_commands_to_dict(commands) ¶
Convert the command list into a format that would be accepted by discord.
Client.interactions should be the variable passed to this
Source code in naff/models/naff/application_commands.py
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 | |
sync_needed(local_cmd, remote_cmd=None) ¶
Compares a local application command to its remote counterpart to determine if a sync is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_cmd | dict | The local json representation of the command | required |
remote_cmd | Optional[dict] | The json representation of the command from Discord | None |
Returns:
| Type | Description |
|---|---|
bool | Boolean indicating if a sync is needed |
Source code in naff/models/naff/application_commands.py
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 | |
Context¶
Resolved ¶
Represents resolved data in an interaction.
Source code in naff/models/naff/context.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
Context ¶
Represents the context of a command.
Source code in naff/models/naff/context.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
bot() property ¶
A reference to the bot instance.
Source code in naff/models/naff/context.py
130 131 132 133 | |
InteractionContext ¶
Bases: _BaseInteractionContext, SendMixin
Represents the context of an interaction.
Ephemeral messages:
Ephemeral messages allow you to send messages that only the author of the interaction can see. They are best considered as fire-and-forget, in the sense that you cannot edit them once they have been sent.
Should you attach a component (ie. button) to the ephemeral message, you will be able to edit it when responding to a button interaction.
Source code in naff/models/naff/context.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
defer(ephemeral=False) async ¶
Defers the response, showing a loading state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ephemeral | bool | Should the response be ephemeral | False |
Source code in naff/models/naff/context.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
send(content=None, embeds=None, embed=None, components=None, stickers=None, allowed_mentions=None, reply_to=None, files=None, file=None, tts=False, suppress_embeds=False, flags=None, ephemeral=False) async ¶
Send a message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[Iterable[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[Iterable[Iterable[Union[BaseComponent, dict]]], Iterable[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[Iterable[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
reply_to | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message to reference, must be from the same channel. | None |
files | Optional[Union[UPLOADABLE_TYPE, Iterable[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
suppress_embeds | bool | Should embeds be suppressed on this send | False |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
ephemeral | bool | Should this message be sent as ephemeral (hidden) | False |
Returns:
| Type | Description |
|---|---|
Message | New message object that was sent. |
Source code in naff/models/naff/context.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
target() property ¶
For context menus, this will be the object of which was clicked on.
Source code in naff/models/naff/context.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
ComponentContext ¶
Bases: InteractionContext
Source code in naff/models/naff/context.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |
from_dict(data, client) classmethod ¶
Create a context object from a dictionary.
Source code in naff/models/naff/context.py
458 459 460 461 462 463 464 465 466 467 468 469 | |
defer(ephemeral=False, edit_origin=False) async ¶
Defers the response, showing a loading state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ephemeral | bool | Should the response be ephemeral | False |
edit_origin | bool | Whether we intend to edit the original message | False |
Source code in naff/models/naff/context.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
edit_origin(content=None, embeds=None, embed=None, components=None, allowed_mentions=None, files=None, file=None, tts=False) async ¶
Edits the original message of the component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content | str | Message text content. | None |
embeds | Optional[Union[Iterable[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[Iterable[Iterable[Union[BaseComponent, dict]]], Iterable[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
files | Optional[Union[UPLOADABLE_TYPE, Iterable[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
Returns:
| Type | Description |
|---|---|
Message | The message after it was edited. |
Source code in naff/models/naff/context.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |
AutocompleteContext ¶
Bases: _BaseInteractionContext
Source code in naff/models/naff/context.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | |
from_dict(data, client) classmethod ¶
Create a context object from a dictionary.
Source code in naff/models/naff/context.py
574 575 576 577 578 579 | |
input_text() property ¶
The text the user has entered so far.
Source code in naff/models/naff/context.py
581 582 583 584 | |
send(choices) async ¶
Send your autocomplete choices to discord. Choices must be either a list of strings, or a dictionary following the following format:
1 2 3 4 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
choices | Iterable[Union[str, int, float, Dict[str, Union[str, int, float]]]] | 25 choices the user can pick | required |
Source code in naff/models/naff/context.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | |
ModalContext ¶
Bases: InteractionContext
Source code in naff/models/naff/context.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |
responses() property ¶
Get the responses to this modal.
Returns:
| Type | Description |
|---|---|
dict[str, str] | A dictionary of responses. Keys are the custom_ids of your components. |
Source code in naff/models/naff/context.py
631 632 633 634 635 636 637 638 639 | |
PrefixedContext ¶
Bases: Context, SendMixin
Source code in naff/models/naff/context.py
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
reply(content=None, embeds=None, embed=None, **kwargs) async ¶
Reply to this message, takes all the same attributes as send.
Source code in naff/models/naff/context.py
661 662 663 664 665 666 667 668 669 | |
HybridContext ¶
Bases: Context
Represents the context for hybrid commands, a slash command that can also be used as a prefixed command.
This attempts to create a compatibility layer to allow contexts for an interaction or a message to be used seamlessly.
Source code in naff/models/naff/context.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | |
inner_context() property ¶
Returns the context powering the current hybrid context.
This can be used for scope-specific actions, like sending modals in an interaction.
Source code in naff/models/naff/context.py
737 738 739 740 741 742 743 744 | |
ephemeral() property ¶
Returns if responses to this interaction are ephemeral, if this is an interaction. Otherwise, returns False.
Source code in naff/models/naff/context.py
746 747 748 749 | |
expires_at() property ¶
The timestamp the context is expected to expire at, or None if the context never expires.
Source code in naff/models/naff/context.py
751 752 753 754 755 756 757 758 759 | |
expired() property ¶
Has the context expired yet?
Source code in naff/models/naff/context.py
761 762 763 764 | |
defer(ephemeral=False) async ¶
Either defers the response (if used in an interaction) or triggers a typing indicator for 10 seconds (if used for messages).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ephemeral | bool | Should the response be ephemeral? Only applies to responses for interactions. | False |
Source code in naff/models/naff/context.py
774 775 776 777 778 779 780 781 782 783 784 785 786 787 | |
reply(content=None, embeds=None, embed=None, **kwargs) async ¶
Reply to this message, takes all the same attributes as send.
For interactions, this functions the same as send.
Source code in naff/models/naff/context.py
789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 | |
send(content=None, embeds=None, embed=None, components=None, stickers=None, allowed_mentions=None, reply_to=None, file=None, tts=False, flags=None, ephemeral=False, **kwargs) async ¶
Send a message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[Iterable[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[Iterable[Iterable[Union[BaseComponent, dict]]], Iterable[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[Iterable[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
reply_to | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message to reference, must be from the same channel. | None |
files | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | required | |
file | Optional[Union[File, IOBase, Path, str]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
suppress_embeds | Should embeds be suppressed on this send | required | |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
ephemeral | bool | Should this message be sent as ephemeral (hidden) - only works with interactions. | False |
Returns:
| Type | Description |
|---|---|
Message | New message object that was sent. |
Source code in naff/models/naff/context.py
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | |
SendableContext ¶
Bases: Protocol
A protocol that supports any context that can send messages.
Use it to type hint something that accepts both PrefixedContext and InteractionContext.
Source code in naff/models/naff/context.py
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 | |
Presence¶
ActivityTimestamps ¶
Bases: DictSerializationMixin
Source code in naff/models/discord/activity.py
21 22 23 24 25 26 | |
start: Optional[Timestamp] = field(default=None, converter=optional(timestamp_converter)) class-attribute ¶
The start time of the activity. Shows "elapsed" timer on discord client.
end: Optional[Timestamp] = field(default=None, converter=optional(timestamp_converter)) class-attribute ¶
The end time of the activity. Shows "remaining" timer on discord client.
ActivityParty ¶
Bases: DictSerializationMixin
Source code in naff/models/discord/activity.py
29 30 31 32 33 34 | |
ActivityAssets ¶
Bases: DictSerializationMixin
Source code in naff/models/discord/activity.py
37 38 39 40 41 42 43 44 45 46 | |
large_image: Optional[str] = field(default=None) class-attribute ¶
The large image for this activity. Uses discord's asset image url format.
large_text: Optional[str] = field(default=None) class-attribute ¶
Hover text for the large image
small_image: Optional[str] = field(default=None) class-attribute ¶
The large image for this activity. Uses discord's asset image url format.
small_text: Optional[str] = field(default=None) class-attribute ¶
Hover text for the small image
ActivitySecrets ¶
Bases: DictSerializationMixin
Source code in naff/models/discord/activity.py
49 50 51 52 53 54 55 56 | |
Activity ¶
Bases: DictSerializationMixin
Represents a discord activity object use for rich presence in discord.
Source code in naff/models/discord/activity.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
name: str = field(repr=True) class-attribute ¶
The activity's name
type: ActivityType = field(repr=True, default=ActivityType.GAME) class-attribute ¶
The type of activity
url: Optional[str] = field(repr=True, default=None) class-attribute ¶
Stream url, is validated when type is 1
created_at: Optional[Timestamp] = field(repr=True, default=None, converter=optional(timestamp_converter)) class-attribute ¶
When the activity was added to the user's session
timestamps: Optional[ActivityTimestamps] = field(default=None, converter=optional(ActivityTimestamps.from_dict)) class-attribute ¶
Start and/or end of the game
application_id: Snowflake_Type = field(default=None) class-attribute ¶
Application id for the game
details: Optional[str] = field(default=None) class-attribute ¶
What the player is currently doing
state: Optional[str] = field(default=None) class-attribute ¶
The user's current party status
emoji: Optional[PartialEmoji] = field(default=None, converter=optional(PartialEmoji.from_dict)) class-attribute ¶
The emoji used for a custom status
party: Optional[ActivityParty] = field(default=None, converter=optional(ActivityParty.from_dict)) class-attribute ¶
Information for the current party of the player
assets: Optional[ActivityAssets] = field(default=None, converter=optional(ActivityAssets.from_dict)) class-attribute ¶
Assets to display on the player's profile
secrets: Optional[ActivitySecrets] = field(default=None, converter=optional(ActivitySecrets.from_dict)) class-attribute ¶
Secrets for Rich Presence joining and spectating
instance: Optional[bool] = field(default=False) class-attribute ¶
Whether or not the activity is an instanced game session
flags: Optional[ActivityFlags] = field(default=None, converter=optional(ActivityFlags)) class-attribute ¶
Activity flags bitwise OR together, describes what the payload includes
buttons: List[str] = field(factory=list) class-attribute ¶
The custom buttons shown in the Rich Presence (max 2)
create(name, type=ActivityType.GAME, url=None) classmethod ¶
Creates an activity object for the bot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | The new activity's name | required |
type | ActivityType | Type of activity to create | ActivityType.GAME |
url | Optional[str] | Stream link for the activity | None |
Returns:
| Type | Description |
|---|---|
Activity | The new activity object |
Source code in naff/models/discord/activity.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
Data¶
Application ¶
Bases: DiscordObject
Represents a discord application.
Source code in naff/models/discord/application.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
name: str = field(repr=True) class-attribute ¶
The name of the application
icon: Optional[Asset] = field(default=None) class-attribute ¶
The icon of the application
description: Optional[str] = field(default=None) class-attribute ¶
The description of the application
rpc_origins: Optional[List[str]] = field(default=None) class-attribute ¶
An array of rpc origin urls, if rpc is enabled
bot_public: bool = field(default=True) class-attribute ¶
When false only app owner can join the app's bot to guilds
bot_require_code_grant: bool = field(default=False) class-attribute ¶
When true the app's bot will only join upon completion of the full oauth2 code grant flow
terms_of_service_url: Optional[str] = field(default=None) class-attribute ¶
The url of the app's terms of service
privacy_policy_url: Optional[str] = field(default=None) class-attribute ¶
The url of the app's privacy policy
owner_id: Optional[Snowflake_Type] = field(default=None, converter=optional(to_snowflake)) class-attribute ¶
The id of the owner of the application
summary: str = field() class-attribute ¶
If this application is a game sold on Discord, this field will be the summary field for the store page of its primary sku
verify_key: Optional[str] = field(default=MISSING) class-attribute ¶
The hex encoded key for verification in interactions and the GameSDK's GetTicket
team: Optional[Team] = field(default=None) class-attribute ¶
If the application belongs to a team, this will be a list of the members of that team
guild_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
If this application is a game sold on Discord, this field will be the guild to which it has been linked
primary_sku_id: Optional[Snowflake_Type] = field(default=None) class-attribute ¶
If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
slug: Optional[str] = field(default=None) class-attribute ¶
If this application is a game sold on Discord, this field will be the URL slug that links to the store page
cover_image: Optional[Asset] = field(default=None) class-attribute ¶
The application's default rich presence invite cover
flags: Optional[ApplicationFlags] = field(default=None, converter=optional(ApplicationFlags)) class-attribute ¶
The application's public flags
tags: Optional[List[str]] = field(default=None) class-attribute ¶
The application's tags describing its functionality and content
install_params: Optional[dict] = field(default=None) class-attribute ¶
The application's settings for in-app invitation to guilds
custom_install_url: Optional[str] = field(default=None) class-attribute ¶
The application's custom authorization link for invitation to a guild
owner() property ¶
The user object for the owner of this application
Source code in naff/models/discord/application.py
82 83 84 85 | |
TeamMember ¶
Bases: DiscordObject
Source code in naff/models/discord/team.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
membership_state: TeamMembershipState = field(converter=TeamMembershipState) class-attribute ¶
Rhe user's membership state on the team
team_id: Snowflake_Type = field(repr=True) class-attribute ¶
Rhe id of the parent team of which they are a member
user: User = field() class-attribute ¶
Rhe avatar, discriminator, id, and username of the user
Team ¶
Bases: DiscordObject
Source code in naff/models/discord/team.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
icon: Optional[Asset] = field(default=None) class-attribute ¶
A hash of the image of the team's icon
members: List[TeamMember] = field(factory=list) class-attribute ¶
The members of the team
name: str = field(repr=True) class-attribute ¶
The name of the team
owner_user_id: Snowflake_Type = field(converter=to_snowflake) class-attribute ¶
The user id of the current team owner
owner() property ¶
The owner of the team
Source code in naff/models/discord/team.py
52 53 54 55 | |
is_in_team(user) ¶
Returns True if the passed user or ID is a member within the team.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user | Union[SnowflakeObject, Snowflake_Type] | The user or user ID to check | required |
Returns:
| Type | Description |
|---|---|
bool | Boolean indicating whether the user is in the team |
Source code in naff/models/discord/team.py
57 58 59 60 61 62 63 64 65 66 67 | |
CursedIntEnum ¶
Bases: IntEnum
Source code in naff/models/discord/enums.py
102 103 104 105 106 | |
WebSocketOPCodes ¶
Bases: CursedIntEnum
Codes used by the Gateway to signify events.
Source code in naff/models/discord/enums.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
DISPATCH = 0 class-attribute ¶
An event was dispatched
HEARTBEAT = 1 class-attribute ¶
Fired periodically by the client to keep the connection alive
IDENTIFY = 2 class-attribute ¶
Starts a new session during the initial handshake.
PRESENCE = 3 class-attribute ¶
Update the client's presence.
VOICE_STATE = 4 class-attribute ¶
Used to join/leave or move between voice channels.
RESUME = 6 class-attribute ¶
Resume a previous session that was disconnected.
RECONNECT = 7 class-attribute ¶
You should attempt to reconnect and resume immediately.
REQUEST_MEMBERS = 8 class-attribute ¶
Request information about offline guild members in a large guild.
INVALIDATE_SESSION = 9 class-attribute ¶
The session has been invalidated. You should reconnect and identify/resume accordingly.
HELLO = 10 class-attribute ¶
Sent immediately after connecting, contains the heartbeat_interval to use.
HEARTBEAT_ACK = 11 class-attribute ¶
Sent in response to receiving a heartbeat to acknowledge that it has been received.
Intents ¶
Bases: DiscordIntFlag
When identifying to the gateway, you can specify an intents parameter which allows you to conditionally subscribe to pre-defined "intents", groups of events defined by Discord.
info
For details about what intents do, or which intents you'll want, please read the Discord API Documentation
Source code in naff/models/discord/enums.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
new(guilds=False, guild_members=False, guild_bans=False, guild_emojis_and_stickers=False, guild_integrations=False, guild_webhooks=False, guild_invites=False, guild_voice_states=False, guild_presences=False, guild_messages=False, guild_message_reactions=False, guild_message_typing=False, direct_messages=False, direct_message_reactions=False, direct_message_typing=False, guild_message_content=False, guild_scheduled_events=False, messages=False, reactions=False, typing=False, privileged=False, non_privileged=False, default=True, all=False) classmethod ¶
Set your desired intents.
Source code in naff/models/discord/enums.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
UserFlags ¶
Bases: DiscordIntFlag
Flags a user can have.
Source code in naff/models/discord/enums.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
DISCORD_EMPLOYEE = 1 << 0 class-attribute ¶
This person works for Discord
PARTNERED_SERVER_OWNER = 1 << 1 class-attribute ¶
User owns a partnered server
HYPESQUAD_EVENTS = 1 << 2 class-attribute ¶
User has helped with a hypesquad event
BUG_HUNTER_LEVEL_1 = 1 << 3 class-attribute ¶
User has passed the bug hunters quiz
HOUSE_BRAVERY = 1 << 6 class-attribute ¶
User belongs to the bravery house
HOUSE_BRILLIANCE = 1 << 7 class-attribute ¶
User belongs to the brilliance house
HOUSE_BALANCE = 1 << 8 class-attribute ¶
User belongs to the balance house
EARLY_SUPPORTER = 1 << 9 class-attribute ¶
This person had Nitro prior to Wednesday, October 10th, 2018
TEAM_USER = 1 << 10 class-attribute ¶
A team user
BUG_HUNTER_LEVEL_2 = 1 << 14 class-attribute ¶
User is a bug hunter level 2
VERIFIED_BOT = 1 << 16 class-attribute ¶
This bot has been verified by Discord
EARLY_VERIFIED_BOT_DEVELOPER = 1 << 17 class-attribute ¶
This user was one of the first to be verified
DISCORD_CERTIFIED_MODERATOR = 1 << 18 class-attribute ¶
This user is a certified moderator
BOT_HTTP_INTERACTIONS = 1 << 19 class-attribute ¶
Bot uses only HTTP interactions and is shown in the online member list
SPAMMER = 1 << 20 class-attribute ¶
A user who is suspected of spamming
DISABLE_PREMIUM = 1 << 21 class-attribute ¶
Nitro features disabled for this user. Only used by Discord Staff for testing
ApplicationFlags ¶
Bases: DiscordIntFlag
Flags an application can have.
Source code in naff/models/discord/enums.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
GATEWAY_PRESENCE = 1 << 12 class-attribute ¶
Verified to use presence intent
GATEWAY_PRESENCE_LIMITED = 1 << 13 class-attribute ¶
Using presence intent, without verification
GATEWAY_GUILD_MEMBERS = 1 << 14 class-attribute ¶
Verified to use guild members intent
GATEWAY_GUILD_MEMBERS_LIMITED = 1 << 15 class-attribute ¶
Using members intent, without verification
VERIFICATION_PENDING_GUILD_LIMIT = 1 << 16 class-attribute ¶
Bot has hit guild limit, and has not been successfully verified
EMBEDDED = 1 << 17 class-attribute ¶
Application is a voice channel activity (ie YouTube Together)
TeamMembershipState ¶
Bases: CursedIntEnum
Status of membership in the team.
Source code in naff/models/discord/enums.py
289 290 291 292 293 | |
PremiumTypes ¶
Bases: CursedIntEnum
Types of premium membership.
Source code in naff/models/discord/enums.py
296 297 298 299 300 301 302 303 304 | |
MessageTypes ¶
Bases: CursedIntEnum
Types of message.
Source code in naff/models/discord/enums.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
EmbedTypes ¶
Bases: Enum
Types of embed.
Source code in naff/models/discord/enums.py
336 337 338 339 340 341 342 343 344 345 | |
MessageActivityTypes ¶
Bases: CursedIntEnum
An activity object, similar to an embed.
Source code in naff/models/discord/enums.py
348 349 350 351 352 353 354 355 356 357 358 | |
MessageFlags ¶
Bases: DiscordIntFlag
Message flags.
Source code in naff/models/discord/enums.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
CROSSPOSTED = 1 << 0 class-attribute ¶
This message has been published to subscribed channels (via Channel Following)
IS_CROSSPOST = 1 << 1 class-attribute ¶
This message originated from a message in another channel (via Channel Following)
SUPPRESS_EMBEDS = 1 << 2 class-attribute ¶
Do not include any embeds when serializing this message
SOURCE_MESSAGE_DELETED = 1 << 3 class-attribute ¶
The source message for this crosspost has been deleted (via Channel Following)
URGENT = 1 << 4 class-attribute ¶
This message came from the urgent message system
HAS_THREAD = 1 << 5 class-attribute ¶
This message has an associated thread, with the same id as the message
EPHEMERAL = 1 << 6 class-attribute ¶
This message is only visible to the user who invoked the Interaction
LOADING = 1 << 7 class-attribute ¶
This message is an Interaction Response and the bot is "thinking
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD = 1 << 8 class-attribute ¶
This message failed to mention some roles and add their members to the thread
SHOULD_SHOW_LINK_NOT_DISCORD_WARNING = 1 << 10 class-attribute ¶
This message contains a abusive website link, pops up a warning when clicked
Permissions ¶
Bases: DiscordIntFlag
Permissions a user or role may have.
Source code in naff/models/discord/enums.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
CREATE_INSTANT_INVITE = 1 << 0 class-attribute ¶
Allows creation of instant invites
KICK_MEMBERS = 1 << 1 class-attribute ¶
Allows kicking members
BAN_MEMBERS = 1 << 2 class-attribute ¶
Allows banning members
ADMINISTRATOR = 1 << 3 class-attribute ¶
Allows all permissions and bypasses channel permission overwrites
MANAGE_CHANNELS = 1 << 4 class-attribute ¶
Allows management and editing of channels
MANAGE_GUILD = 1 << 5 class-attribute ¶
Allows management and editing of the guild
ADD_REACTIONS = 1 << 6 class-attribute ¶
Allows for the addition of reactions to messages
VIEW_AUDIT_LOG = 1 << 7 class-attribute ¶
Allows for viewing of audit logs
PRIORITY_SPEAKER = 1 << 8 class-attribute ¶
Allows for using priority speaker in a voice channel
STREAM = 1 << 9 class-attribute ¶
Allows the user to go live
VIEW_CHANNEL = 1 << 10 class-attribute ¶
Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels
SEND_MESSAGES = 1 << 11 class-attribute ¶
Allows for sending messages in a channel (does not allow sending messages in threads)
CREATE_POSTS = 1 << 11 class-attribute ¶
Allow members to create posts in this channel. Alias to SEND_MESSAGES
SEND_TTS_MESSAGES = 1 << 12 class-attribute ¶
Allows for sending of /tts messages
MANAGE_MESSAGES = 1 << 13 class-attribute ¶
Allows for deletion of other users messages
EMBED_LINKS = 1 << 14 class-attribute ¶
Links sent by users with this permission will be auto-embedded
ATTACH_FILES = 1 << 15 class-attribute ¶
Allows for uploading images and files
READ_MESSAGE_HISTORY = 1 << 16 class-attribute ¶
Allows for reading of message history
MENTION_EVERYONE = 1 << 17 class-attribute ¶
Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel
USE_EXTERNAL_EMOJIS = 1 << 18 class-attribute ¶
Allows the usage of custom emojis from other servers
VIEW_GUILD_INSIGHTS = 1 << 19 class-attribute ¶
Allows for viewing guild insights
CONNECT = 1 << 20 class-attribute ¶
Allows for joining of a voice channel
SPEAK = 1 << 21 class-attribute ¶
Allows for speaking in a voice channel
MUTE_MEMBERS = 1 << 22 class-attribute ¶
Allows for muting members in a voice channel
DEAFEN_MEMBERS = 1 << 23 class-attribute ¶
Allows for deafening of members in a voice channel
MOVE_MEMBERS = 1 << 24 class-attribute ¶
Allows for moving of members between voice channels
USE_VAD = 1 << 25 class-attribute ¶
Allows for using voice-activity-detection in a voice channel
CHANGE_NICKNAME = 1 << 26 class-attribute ¶
Allows for modification of own nickname
MANAGE_NICKNAMES = 1 << 27 class-attribute ¶
Allows for modification of other users nicknames
MANAGE_ROLES = 1 << 28 class-attribute ¶
Allows management and editing of roles
MANAGE_WEBHOOKS = 1 << 29 class-attribute ¶
Allows management and editing of webhooks
MANAGE_EMOJIS_AND_STICKERS = 1 << 30 class-attribute ¶
Allows management and editing of emojis and stickers
USE_APPLICATION_COMMANDS = 1 << 31 class-attribute ¶
Allows members to use application commands, including slash commands and context menu commands
REQUEST_TO_SPEAK = 1 << 32 class-attribute ¶
Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.)
MANAGE_EVENTS = 1 << 33 class-attribute ¶
Allows for creating, editing, and deleting scheduled events
MANAGE_THREADS = 1 << 34 class-attribute ¶
Allows for deleting and archiving threads, and viewing all private threads
USE_PUBLIC_THREADS = 1 << 35 class-attribute ¶
Allows for creating public and announcement threads
USE_PRIVATE_THREADS = 1 << 36 class-attribute ¶
Allows for creating private threads
USE_EXTERNAL_STICKERS = 1 << 37 class-attribute ¶
Allows the usage of custom stickers from other servers
SEND_MESSAGES_IN_THREADS = 1 << 38 class-attribute ¶
Allows for sending messages in threads
START_EMBEDDED_ACTIVITIES = 1 << 39 class-attribute ¶
Allows for using Activities (applications with the EMBEDDED flag) in a voice channel
MODERATE_MEMBERS = 1 << 40 class-attribute ¶
Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels
USE_SLASH_COMMANDS = USE_APPLICATION_COMMANDS class-attribute ¶
Legacy alias for :attr:USE_APPLICATION_COMMANDS
ChannelTypes ¶
Bases: CursedIntEnum
Types of channel.
Source code in naff/models/discord/enums.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | |
GUILD_TEXT = 0 class-attribute ¶
Text channel within a server
DM = 1 class-attribute ¶
Direct message between users
GUILD_VOICE = 2 class-attribute ¶
Voice channel within a server
GROUP_DM = 3 class-attribute ¶
Direct message between multiple users
GUILD_CATEGORY = 4 class-attribute ¶
Organizational category that contains up to 50 channels
GUILD_NEWS = 5 class-attribute ¶
Channel that users can follow and crosspost into their own server
GUILD_NEWS_THREAD = 10 class-attribute ¶
Temporary sub-channel within a GUILD_NEWS channel
GUILD_PUBLIC_THREAD = 11 class-attribute ¶
Temporary sub-channel within a GUILD_TEXT channel
GUILD_PRIVATE_THREAD = 12 class-attribute ¶
Temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission
GUILD_STAGE_VOICE = 13 class-attribute ¶
Voice channel for hosting events with an audience
GUILD_FORUM = 15 class-attribute ¶
A Forum channel
guild() property ¶
Whether this channel is a guild channel.
Source code in naff/models/discord/enums.py
527 528 529 530 | |
voice() property ¶
Whether this channel is a voice channel.
Source code in naff/models/discord/enums.py
532 533 534 535 | |
ComponentTypes ¶
Bases: CursedIntEnum
The types of components supported by discord.
Source code in naff/models/discord/enums.py
538 539 540 541 542 543 544 545 546 547 548 | |
CommandTypes ¶
Bases: CursedIntEnum
The interaction commands supported by discord.
Source code in naff/models/discord/enums.py
551 552 553 554 555 556 557 558 559 | |
CHAT_INPUT = 1 class-attribute ¶
Slash commands; a text-based command that shows up when a user types /
USER = 2 class-attribute ¶
A UI-based command that shows up when you right click or tap on a user
MESSAGE = 3 class-attribute ¶
A UI-based command that shows up when you right click or tap on a message
InteractionTypes ¶
Bases: CursedIntEnum
The type of interaction received by discord.
Source code in naff/models/discord/enums.py
562 563 564 565 566 567 568 569 | |
ButtonStyles ¶
Bases: CursedIntEnum
The styles of buttons supported.
Source code in naff/models/discord/enums.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | |
MentionTypes ¶
Bases: str, Enum
Types of mention.
Source code in naff/models/discord/enums.py
597 598 599 600 601 602 | |
OverwriteTypes ¶
Bases: CursedIntEnum
Types of permission overwrite.
Source code in naff/models/discord/enums.py
605 606 607 608 609 | |
DefaultNotificationLevels ¶
Bases: CursedIntEnum
Default Notification levels for dms and guilds.
Source code in naff/models/discord/enums.py
612 613 614 615 616 | |
ExplicitContentFilterLevels ¶
Bases: CursedIntEnum
Automatic filtering of explicit content.
Source code in naff/models/discord/enums.py
619 620 621 622 623 624 | |
MFALevels ¶
Bases: CursedIntEnum
Does the user use 2FA.
Source code in naff/models/discord/enums.py
627 628 629 630 631 | |
VerificationLevels ¶
Bases: CursedIntEnum
Levels of verification needed by a guild.
Source code in naff/models/discord/enums.py
634 635 636 637 638 639 640 641 642 643 644 645 646 | |
NONE = 0 class-attribute ¶
No verification needed
LOW = 1 class-attribute ¶
Must have a verified email on their Discord Account
MEDIUM = 2 class-attribute ¶
Must also be registered on Discord for longer than 5 minutes
HIGH = 3 class-attribute ¶
Must also be a member of this server for longer than 10 minutes
VERY_HIGH = 4 class-attribute ¶
Must have a verified phone number on their Discord Account
NSFWLevels ¶
Bases: CursedIntEnum
A guilds NSFW Level.
Source code in naff/models/discord/enums.py
649 650 651 652 653 654 655 | |
PremiumTiers ¶
Bases: CursedIntEnum
The boost level of a server.
Source code in naff/models/discord/enums.py
658 659 660 661 662 663 664 665 666 667 668 | |
SystemChannelFlags ¶
Bases: DiscordIntFlag
System channel settings.
Source code in naff/models/discord/enums.py
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0 class-attribute ¶
Suppress member join notifications
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1 class-attribute ¶
Suppress server boost notifications
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS = 1 << 2 class-attribute ¶
Suppress server setup tips
SUPPRESS_JOIN_NOTIFICATION_REPLIES = 1 << 3 class-attribute ¶
Hide member join sticker reply buttons
ChannelFlags ¶
Bases: DiscordIntFlag
Source code in naff/models/discord/enums.py
688 689 690 691 692 693 | |
PINNED = 1 << 1 class-attribute ¶
Thread is pinned to the top of its parent forum channel
VideoQualityModes ¶
Bases: CursedIntEnum
Video quality settings.
Source code in naff/models/discord/enums.py
696 697 698 699 700 | |
AutoArchiveDuration ¶
Bases: CursedIntEnum
Thread archive duration, in minutes.
Source code in naff/models/discord/enums.py
703 704 705 706 707 708 709 | |
ActivityType ¶
Bases: CursedIntEnum
The types of presence activity that can be used in presences.
Note
Only GAME STREAMING LISTENING WATCHING and COMPETING are usable by bots
Source code in naff/models/discord/enums.py
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 | |
GAME = 0 class-attribute ¶
Playing {name}; Example: Playing Rocket League
STREAMING = 1 class-attribute ¶
Streaming {details}; Example: Streaming Rocket League
LISTENING = 2 class-attribute ¶
Listening to {name}; Example: Listening to Spotify
WATCHING = 3 class-attribute ¶
Watching {name}; Example: Watching YouTube Together
CUSTOM = 4 class-attribute ¶
{emoji} {name}; Example: :smiley: I am cool
COMPETING = 5 class-attribute ¶
Competing in {name}; Example: Competing in Arena World Champions
PLAYING = GAME class-attribute ¶
Alias for GAME
Status ¶
Bases: str, Enum
Represents the statuses a user may have.
Source code in naff/models/discord/enums.py
750 751 752 753 754 755 756 757 758 759 760 | |
ScheduledEventPrivacyLevel ¶
Bases: CursedIntEnum
The privacy level of the scheduled event.
Source code in naff/models/discord/enums.py
778 779 780 781 | |
ScheduledEventType ¶
Bases: CursedIntEnum
The type of entity that the scheduled event is attached to.
Source code in naff/models/discord/enums.py
784 785 786 787 788 789 790 791 792 | |
ScheduledEventStatus ¶
Bases: CursedIntEnum
The status of the scheduled event.
Source code in naff/models/discord/enums.py
795 796 797 798 799 800 801 | |
AuditLogEventType ¶
Bases: CursedIntEnum
The type of audit log entry type
Source code in naff/models/discord/enums.py
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | |
Timestamp ¶
Bases: datetime
A special class that represents Discord timestamps.
Assumes that all naive datetimes are based on local timezone.
Source code in naff/models/discord/timestamp.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
fromdatetime(dt) classmethod ¶
Construct a timezone-aware UTC datetime from a datetime object.
Source code in naff/models/discord/timestamp.py
32 33 34 35 36 37 38 39 | |
utcfromtimestamp(t) classmethod ¶
Construct a timezone-aware UTC datetime from a POSIX timestamp.
Source code in naff/models/discord/timestamp.py
41 42 43 44 | |
now(tz=None) classmethod ¶
Construct a datetime from time.time() and optional time zone info.
If no timezone is provided, the time is assumed to be from the computer's local timezone.
Source code in naff/models/discord/timestamp.py
74 75 76 77 78 79 80 81 82 83 | |
utcnow() classmethod ¶
Construct a timezone-aware UTC datetime from time.time().
Source code in naff/models/discord/timestamp.py
85 86 87 88 89 | |
to_snowflake(high=False) ¶
Returns a numeric snowflake pretending to be created at the given date.
When using as the lower end of a range, use tosnowflake(high=False) - 1 to be inclusive, high=True to be exclusive. When using as the higher end of a range, use tosnowflake(high=True) + 1 to be inclusive, high=False to be exclusive
Source code in naff/models/discord/timestamp.py
91 92 93 94 95 96 97 98 99 100 101 102 | |
from_snowflake(snowflake) classmethod ¶
Construct a timezone-aware UTC datetime from a snowflake.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snowflake | Snowflake_Type | The snowflake to convert. | required |
Returns:
| Type | Description |
|---|---|
Timestamp | A timezone-aware UTC datetime. |
Info
https://discord.com/developers/docs/reference#convert-snowflake-to-datetime
Source code in naff/models/discord/timestamp.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
format(style=None) ¶
Format the timestamp for discord client to display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style | Optional[Union[TimestampStyles, str]] | The style to format the timestamp with. | None |
Returns:
| Type | Description |
|---|---|
str | The formatted timestamp. |
Source code in naff/models/discord/timestamp.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
naff Models¶
Extension ¶
A class that allows you to separate your commands and listeners into separate files. Skins require an entrypoint in the same file called setup, this function allows client to load the Extension.
Example Usage:
1 2 3 4 5 6 7 | |
Attributes:
| Name | Type | Description |
|---|---|---|
bot | Client | A reference to the client |
name | str | The name of this Extension ( |
description | str | A description of this Extension |
extension_checks | str | A list of checks to be ran on any command in this extension |
extension_prerun | List | A list of coroutines to be run before any command in this extension |
extension_postrun | List | A list of coroutines to be run after any command in this extension |
Source code in naff/models/naff/extension.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
commands() property ¶
Get the commands from this Extension.
Source code in naff/models/naff/extension.py
123 124 125 126 | |
listeners() property ¶
Get the listeners from this Extension.
Source code in naff/models/naff/extension.py
128 129 130 131 | |
drop() ¶
Called when this Extension is being removed.
Source code in naff/models/naff/extension.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
add_ext_auto_defer(ephemeral=False, time_until_defer=0.0) ¶
Add a auto defer for all commands in this extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ephemeral | bool | Should the command be deferred as ephemeral | False |
time_until_defer | float | How long to wait before deferring automatically | 0.0 |
Source code in naff/models/naff/extension.py
202 203 204 205 206 207 208 209 210 211 | |
add_ext_check(coroutine) ¶
Add a coroutine as a check for all commands in this extension to run. This coroutine must take only the parameter context.
Example Usage:
1 2 3 4 5 6 7 8 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coroutine | Callable[[Context], Awaitable[bool]] | The coroutine to use as a check | required |
Source code in naff/models/naff/extension.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
add_extension_prerun(coroutine) ¶
Add a coroutine to be run before all commands in this Extension.
Note
Pre-runs will only be run if the commands checks pass
Example Usage:
1 2 3 4 5 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coroutine | Callable[..., Coroutine] | The coroutine to run | required |
Source code in naff/models/naff/extension.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
add_extension_postrun(coroutine) ¶
Add a coroutine to be run after all commands in this Extension.
Example Usage:
1 2 3 4 5 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coroutine | Callable[..., Coroutine] | The coroutine to run | required |
Source code in naff/models/naff/extension.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
set_extension_error(coroutine) ¶
Add a coroutine to handle any exceptions raised in this extension.
Example Usage:
```python def init(self, bot): self.set_extension_error(self.example)
Args: coroutine: The coroutine to run
Source code in naff/models/naff/extension.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
Buckets ¶
Bases: IntEnum
Outlines the cooldown buckets that may be used. Should a bucket for guilds exist, and the command is invoked in a DM, a sane default will be used.
Note
To add your own, override this
Source code in naff/models/naff/cooldowns.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
DEFAULT = 0 class-attribute ¶
Default is the same as user
USER = 1 class-attribute ¶
Per user cooldowns
GUILD = 2 class-attribute ¶
Per guild cooldowns
CHANNEL = 3 class-attribute ¶
Per channel cooldowns
MEMBER = 4 class-attribute ¶
Per guild member cooldowns
CATEGORY = 5 class-attribute ¶
Per category cooldowns
ROLE = 6 class-attribute ¶
Per role cooldowns
Cooldown ¶
Manages cooldowns and their respective buckets for a command.
Source code in naff/models/naff/cooldowns.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
acquire_token(context) async ¶
Attempt to acquire a token for a command to run. Uses the context of the command to use the correct CooldownSystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context | Context | The context of the command | required |
Returns:
| Type | Description |
|---|---|
bool | True if a token was acquired, False if not |
Source code in naff/models/naff/cooldowns.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
get_cooldown_time(context) async ¶
Get the remaining cooldown time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context | Context | The context of the command | required |
Returns:
| Type | Description |
|---|---|
float | remaining cooldown time, will return 0 if the cooldown has not been reached |
Source code in naff/models/naff/cooldowns.py
91 92 93 94 95 96 97 98 99 100 101 102 103 | |
on_cooldown(context) async ¶
Returns the cooldown state of the command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context | Context | The context of the command | required |
Returns:
| Type | Description |
|---|---|
bool | boolean state if the command is on cooldown or not |
Source code in naff/models/naff/cooldowns.py
105 106 107 108 109 110 111 112 113 114 115 116 117 | |
reset_all() async ¶
Resets this cooldown system to its initial state.
!!! warning To be clear, this will reset all cooldowns for this command to their initial states
Source code in naff/models/naff/cooldowns.py
119 120 121 122 123 124 125 126 127 128 | |
reset(context) async ¶
Resets the cooldown for the bucket of which invoked this command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context | Context | The context of the command | required |
Source code in naff/models/naff/cooldowns.py
130 131 132 133 134 135 136 137 138 139 | |
CooldownSystem ¶
Represents a cooldown system for commands.
Attributes:
| Name | Type | Description |
|---|---|---|
rate | int | How many commands may be ran per interval |
interval | float | How many seconds to wait for a cooldown |
opened | float | When this cooldown session began |
Source code in naff/models/naff/cooldowns.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
reset() ¶
Resets the tokens for this cooldown.
Source code in naff/models/naff/cooldowns.py
168 169 170 171 | |
on_cooldown() ¶
Returns the cooldown state of the command.
Returns:
| Type | Description |
|---|---|
bool | boolean state if the command is on cooldown or not |
Source code in naff/models/naff/cooldowns.py
173 174 175 176 177 178 179 180 181 182 183 184 | |
acquire_token() ¶
Attempt to acquire a token for a command to run.
Returns:
| Type | Description |
|---|---|
bool | True if a token was acquired, False if not |
Source code in naff/models/naff/cooldowns.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
get_cooldown_time() ¶
Returns how long until the cooldown will reset.
Returns:
| Type | Description |
|---|---|
float | remaining cooldown time, will return 0 if the cooldown has not been reached |
Source code in naff/models/naff/cooldowns.py
204 205 206 207 208 209 210 211 212 213 214 215 | |
determine_cooldown() ¶
Determines the state of the cooldown system.
Source code in naff/models/naff/cooldowns.py
217 218 219 220 221 222 223 | |
MaxConcurrency ¶
Limits how many instances of a command may be running concurrently.
Attributes:
| Name | Type | Description |
|---|---|---|
bucket | Buckets | The bucket this concurrency applies to |
concurrent | int | The maximum number of concurrent instances permitted to |
wait | bool | Should we wait until a instance is available |
Source code in naff/models/naff/cooldowns.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
get_semaphore(context) async ¶
Get the semaphore associated with the given context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context | Context | The commands context | required |
Returns:
| Type | Description |
|---|---|
asyncio.Semaphore | A semaphore object |
Source code in naff/models/naff/cooldowns.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
acquire(context) async ¶
Acquire an instance of the semaphore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context | Context | The context of the command | required |
Returns:
| Type | Description |
|---|---|
bool | If the semaphore was successfully acquired |
Source code in naff/models/naff/cooldowns.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
release(context) async ¶
Release the semaphore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context | Context | The context of the command | required |
Source code in naff/models/naff/cooldowns.py
278 279 280 281 282 283 284 285 286 287 288 | |
has_role(role) ¶
Check if the user has the given role.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role | Snowflake_Type | Role | The Role or role id to check for | required |
Source code in naff/models/naff/checks.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
has_any_role(*roles) ¶
Checks if the user has any of the given roles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*roles | Snowflake_Type | Role | The Role(s) or role id(s) to check for | () |
Source code in naff/models/naff/checks.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
has_id(user_id) ¶
Checks if the author has the desired ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id | int | id of the user to check for | required |
Source code in naff/models/naff/checks.py
53 54 55 56 57 58 59 60 61 62 63 64 65 | |
is_owner() ¶
Checks if the author is the owner of the bot. This respects the client.owner_ids list.
Source code in naff/models/naff/checks.py
68 69 70 71 72 73 74 75 76 77 | |
guild_only() ¶
This command may only be ran in a guild.
Source code in naff/models/naff/checks.py
80 81 82 83 84 85 86 | |
dm_only() ¶
This command may only be ran in a dm.
Source code in naff/models/naff/checks.py
89 90 91 92 93 94 95 | |
A decorator to add an auto defer to a application command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ephemeral | bool | Should the command be deferred as ephemeral | False |
time_until_defer | float | How long to wait before deferring automatically | 0.0 |
Source code in naff/models/naff/application_commands.py
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | |
CMD_BODY ¶
Bases: NoArgumentConverter[str]
This argument is for the body of the message.
IE:
if @bot hello how are you? is sent this argument will be hello how are you?
Source code in naff/models/naff/annotations/argument.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
convert(context, _) async ¶
Returns the body of the message.
Source code in naff/models/naff/annotations/argument.py
23 24 25 26 27 | |
slash_str_option(description, required=False, autocomplete=False, choices=None, min_length=None, max_length=None) ¶
Annotates an argument as a string type slash command option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | The choices allowed by this command | None |
min_length | Optional[int] | The minimum length of text a user can input. | None |
max_length | Optional[int] | The maximum length of text a user can input. | None |
Source code in naff/models/naff/annotations/slash.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
CMD_AUTHOR ¶
Bases: NoArgumentConverter
This argument is the author of the context.
Source code in naff/models/naff/annotations/argument.py
30 31 32 33 34 35 | |
convert(context, _) async ¶
Returns the author of the context.
Source code in naff/models/naff/annotations/argument.py
33 34 35 | |
CMD_CHANNEL ¶
Bases: NoArgumentConverter
This argument is the channel the command was sent in.
Source code in naff/models/naff/annotations/argument.py
38 39 40 41 42 43 | |
convert(context, _) async ¶
Returns the channel of the context.
Source code in naff/models/naff/annotations/argument.py
41 42 43 | |
CMD_ARGS ¶
Bases: NoArgumentConverter[list[str]]
This argument is all of the arguments sent with this context.
Source code in naff/models/naff/annotations/argument.py
46 47 48 49 50 51 52 | |
convert(context, _) async staticmethod ¶
Returns the arguments for this context.
Source code in naff/models/naff/annotations/argument.py
49 50 51 52 | |
slash_float_option(description, required=False, autocomplete=False, choices=None, min_value=None, max_value=None) ¶
Annotates an argument as a float type slash command option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | The choices allowed by this command | None |
min_value | Optional[float] | The minimum number allowed | None |
max_value | Optional[float] | The maximum number allowed | None |
Source code in naff/models/naff/annotations/slash.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
slash_int_option(description, required=False, autocomplete=False, choices=None, min_value=None, max_value=None) ¶
Annotates an argument as a integer type slash command option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | The choices allowed by this command | None |
min_value | Optional[float] | The minimum number allowed | None |
max_value | Optional[float] | The maximum number allowed | None |
Source code in naff/models/naff/annotations/slash.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
slash_bool_option(description, required=False) ¶
Annotates an argument as a boolean type slash command option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
Source code in naff/models/naff/annotations/slash.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
slash_user_option(description, required=False, autocomplete=False) ¶
Annotates an argument as a user type slash command option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
Source code in naff/models/naff/annotations/slash.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
slash_channel_option(description, required=False, autocomplete=False, choices=None, channel_types=None) ¶
Annotates an argument as a channel type slash command option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | The choices allowed by this command | None |
channel_types | Optional[list[Union[ChannelTypes, int]]] | The types of channel allowed by this option | None |
Source code in naff/models/naff/annotations/slash.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
slash_role_option(description, required=False, autocomplete=False, choices=None) ¶
Annotates an argument as a role type slash command option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | The choices allowed by this command | None |
Source code in naff/models/naff/annotations/slash.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
slash_mentionable_option(description, required=False, autocomplete=False, choices=None) ¶
Annotates an argument as a mentionable type slash command option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | The choices allowed by this command | None |
Source code in naff/models/naff/annotations/slash.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
slash_attachment_option(description, required=False) ¶
Annotates an argument as an attachment type slash command option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
Source code in naff/models/naff/annotations/slash.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
NoArgumentConverter ¶
Bases: Converter[T_co]
An indicator class for special type of converters that only uses the Context.
This is mainly needed for prefixed commands, as arguments will be "eaten up" by converters otherwise.
Source code in naff/models/naff/converters.py
74 75 76 77 78 79 | |
IDConverter ¶
Bases: Converter[T_co]
The base converter for objects that have snowflake IDs.
Source code in naff/models/naff/converters.py
104 105 106 107 108 109 | |
SnowflakeConverter ¶
Bases: IDConverter[SnowflakeObject]
Converts a string argument to a SnowflakeObject.
Source code in naff/models/naff/converters.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
convert(ctx, argument) async ¶
Converts a given string to a SnowflakeObject.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By role or channel mention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
| Name | Type | Description |
|---|---|---|
SnowflakeObject | SnowflakeObject | The converted object. |
Source code in naff/models/naff/converters.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
ChannelConverter ¶
Bases: IDConverter[T_co]
The base converter for channel objects.
Source code in naff/models/naff/converters.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
convert(ctx, argument) async ¶
Converts a given string to a Channel object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By channel mention.
-
By name - the bot will search in a guild if the context has it, otherwise it will search globally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseChannel | T_co | The converted object. |
T_co | The channel type will be of the type the converter represents. |
Source code in naff/models/naff/converters.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
UserConverter ¶
Bases: IDConverter[User]
Converts a string argument to a User object.
Source code in naff/models/naff/converters.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
convert(ctx, argument) async ¶
Converts a given string to a User object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By mention.
-
By username + tag (ex User#1234).
-
By username.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
| Name | Type | Description |
|---|---|---|
User | User | The converted object. |
Source code in naff/models/naff/converters.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
MemberConverter ¶
Bases: IDConverter[Member]
Converts a string argument to a Member object.
Source code in naff/models/naff/converters.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
convert(ctx, argument) async ¶
Converts a given string to a Member object. This will only work in guilds.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By mention.
-
By username + tag (ex User#1234).
-
By nickname.
-
By username.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Member | Member | The converted object. |
Source code in naff/models/naff/converters.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
MessageConverter ¶
Converts a string argument to a Message object.
Source code in naff/models/naff/converters.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
convert(ctx, argument) async ¶
Converts a given string to a Message object.
The lookup strategy is as follows:
-
By raw snowflake ID. The message must be in the same channel as the context.
-
By message + channel ID in the format of "{Channel ID}-{Message ID}". This can be obtained by shift clicking "Copy ID" when Developer Mode is enabled.
-
By message link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Message | Message | The converted object. |
Source code in naff/models/naff/converters.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
GuildConverter ¶
Bases: IDConverter[Guild]
Converts a string argument to a Guild object.
Source code in naff/models/naff/converters.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
convert(ctx, argument) async ¶
Converts a given string to a Guild object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Guild | Guild | The converted object. |
Source code in naff/models/naff/converters.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
RoleConverter ¶
Bases: IDConverter[Role]
Converts a string argument to a Role object.
Source code in naff/models/naff/converters.py
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
convert(ctx, argument) async ¶
Converts a given string to a Role object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By mention.
-
By name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Role | Role | The converted object. |
Source code in naff/models/naff/converters.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
PartialEmojiConverter ¶
Bases: IDConverter[PartialEmoji]
Converts a string argument to a PartialEmoji object.
Source code in naff/models/naff/converters.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
convert(ctx, argument) async ¶
Converts a given string to a PartialEmoji object.
This converter only accepts emoji strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
| Name | Type | Description |
|---|---|---|
PartialEmoji | PartialEmoji | The converted object. |
Source code in naff/models/naff/converters.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
CustomEmojiConverter ¶
Bases: IDConverter[CustomEmoji]
Converts a string argument to a CustomEmoji object.
Source code in naff/models/naff/converters.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
convert(ctx, argument) async ¶
Converts a given string to a CustomEmoji object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By the emoji string format.
-
By name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx | Context | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
| Name | Type | Description |
|---|---|---|
CustomEmoji | CustomEmoji | The converted object. |
Source code in naff/models/naff/converters.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
Greedy ¶
Bases: List[T]
A special marker class to mark an argument in a prefixed command to repeatedly convert until it fails to convert an argument.
Source code in naff/models/naff/converters.py
569 570 | |
NAFF_MODEL_TO_CONVERTER: dict[type, type[Converter]] = {SnowflakeObject: SnowflakeConverter, BaseChannel: BaseChannelConverter, DMChannel: DMChannelConverter, DM: DMConverter, DMGroup: DMGroupConverter, GuildChannel: GuildChannelConverter, GuildNews: GuildNewsConverter, GuildCategory: GuildCategoryConverter, GuildText: GuildTextConverter, ThreadChannel: ThreadChannelConverter, GuildNewsThread: GuildNewsThreadConverter, GuildPublicThread: GuildPublicThreadConverter, GuildPrivateThread: GuildPrivateThreadConverter, VoiceChannel: VoiceChannelConverter, GuildVoice: GuildVoiceConverter, GuildStageVoice: GuildStageVoiceConverter, TYPE_ALL_CHANNEL: BaseChannelConverter, TYPE_DM_CHANNEL: DMChannelConverter, TYPE_GUILD_CHANNEL: GuildChannelConverter, TYPE_THREAD_CHANNEL: ThreadChannelConverter, TYPE_VOICE_CHANNEL: VoiceChannelConverter, TYPE_MESSAGEABLE_CHANNEL: MessageableChannelConverter, User: UserConverter, Member: MemberConverter, Message: MessageConverter, Guild: GuildConverter, Role: RoleConverter, PartialEmoji: PartialEmojiConverter, CustomEmoji: CustomEmojiConverter} module-attribute ¶
A dictionary mapping of naff objects to their corresponding converters.
Listener ¶
Bases: CallbackObject
Source code in naff/models/naff/listener.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
create(event_name=MISSING) classmethod ¶
Decorator for creating an event listener.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name | Absent[str | BaseEvent] | The name of the event to listen to. If left blank, event name will be inferred from the function name or parameter. | MISSING |
Returns:
| Type | Description |
|---|---|
Callable[[Coroutine], Listener] | A listener object. |
Source code in naff/models/naff/listener.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
listen(event_name=MISSING) ¶
Decorator to make a function an event listener.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name | Absent[str | BaseEvent] | The name of the event to listen to. If left blank, event name will be inferred from the function name or parameter. | MISSING |
Returns:
| Type | Description |
|---|---|
Callable[[Callable[..., Coroutine]], Listener] | A listener object. |
Source code in naff/models/naff/listener.py
63 64 65 66 67 68 69 70 71 72 73 74 | |
LocalisedField ¶
An object that enables support for localising fields.
Supported locales: https://discord.com/developers/docs/reference#locales
Source code in naff/models/naff/localisation.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
default() property ¶
The default value based on the CONST default_locale
Source code in naff/models/naff/localisation.py
69 70 71 72 | |
get_locale(locale) ¶
Get the value for the specified locale. Supports locale-codes and locale names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locale | str | The locale to fetch | required |
Returns:
| Type | Description |
|---|---|
str | The localised string, or the default value |
Source code in naff/models/naff/localisation.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
BaseTrigger ¶
Bases: ABC
Source code in naff/models/naff/tasks/triggers.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
next_fire() abstractmethod ¶
Return the next datetime to fire on.
Returns:
| Type | Description |
|---|---|
datetime | None | Datetime if one can be determined. If no datetime can be determined, return None |
Source code in naff/models/naff/tasks/triggers.py
18 19 20 21 22 23 24 25 26 27 | |
Task ¶
Create an asynchronous background tasks. Tasks allow you to run code according to a trigger object.
A task's trigger must inherit from BaseTrigger.
Attributes:
| Name | Type | Description |
|---|---|---|
callback | Callable | The function to be called when the trigger is triggered. |
trigger | BaseTrigger | The trigger object that determines when the task should run. |
task | Optional[_Task] | The task object that is running the trigger loop. |
iteration | int | The number of times the task has run. |
Source code in naff/models/naff/tasks/task.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
started() property ¶
Whether the task is started
Source code in naff/models/naff/tasks/task.py
43 44 45 46 | |
running() property ¶
Whether the task is running
Source code in naff/models/naff/tasks/task.py
48 49 50 51 | |
done() property ¶
Whether the task is done/finished
Source code in naff/models/naff/tasks/task.py
53 54 55 56 | |
next_run() property ¶
Get the next datetime this task will run.
Source code in naff/models/naff/tasks/task.py
58 59 60 61 62 63 64 | |
delta_until_run() property ¶
Get the time until the next run of this task.
Source code in naff/models/naff/tasks/task.py
66 67 68 69 70 71 72 73 | |
on_error_sentry_hook(error) ¶
A dummy method for naff.ext.sentry to hook
Source code in naff/models/naff/tasks/task.py
75 76 | |
on_error(error) ¶
Error handler for this task. Called when an exception is raised during execution of the task.
Source code in naff/models/naff/tasks/task.py
78 79 80 81 | |
start() ¶
Start this task.
Source code in naff/models/naff/tasks/task.py
117 118 119 120 121 122 123 124 125 | |
stop() ¶
End this task.
Source code in naff/models/naff/tasks/task.py
127 128 129 130 131 | |
restart() ¶
Restart this task.
Source code in naff/models/naff/tasks/task.py
133 134 135 136 | |
reschedule(trigger) ¶
Change the trigger being used by this task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trigger | BaseTrigger | The new Trigger to use | required |
Source code in naff/models/naff/tasks/task.py
138 139 140 141 142 143 144 145 146 147 | |
create(trigger) classmethod ¶
A decorator to create a task.
Example
1 2 3 4 5 6 7 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trigger | BaseTrigger | The trigger to use for this task | required |
Source code in naff/models/naff/tasks/task.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
IntervalTrigger ¶
Bases: BaseTrigger
Trigger the task every set interval.
Attributes:
| Name | Type | Description |
|---|---|---|
seconds | Union[int, float] | How many seconds between intervals |
minutes | Union[int, float] | How many minutes between intervals |
hours | Union[int, float] | How many hours between intervals |
days | Union[int, float] | How many days between intervals |
weeks | Union[int, float] | How many weeks between intervals |
Source code in naff/models/naff/tasks/triggers.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
DateTrigger ¶
Bases: BaseTrigger
Trigger the task once, when the specified datetime is reached.
Attributes:
| Name | Type | Description |
|---|---|---|
target_datetime | datetime | A datetime representing the date/time to run this task |
Source code in naff/models/naff/tasks/triggers.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
TimeTrigger ¶
Bases: BaseTrigger
Trigger the task every day, at a specified (24 hour clock) time.
Attributes:
| Name | Type | Description |
|---|---|---|
hour | int | The hour of the day (24 hour clock) |
minute | int | The minute of the hour |
seconds | int | The seconds of the minute |
utc | bool | If this time is in UTC |
Source code in naff/models/naff/tasks/triggers.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
OrTrigger ¶
Bases: BaseTrigger
Trigger a task when any sub-trigger is fulfilled.
Source code in naff/models/naff/tasks/triggers.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
Wait ¶
Class for waiting for a future event to happen. Internally used by wait_for.
Source code in naff/models/naff/wait.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
AsyncIterator ¶
Bases: _AsyncIterator, ABC
Source code in naff/models/misc/iterator.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
last: Absent[Any] = MISSING instance-attribute ¶
The last item retrieved
get_limit() property ¶
Get how the maximum number of items that should be retrieved.
Source code in naff/models/misc/iterator.py
34 35 36 37 | |
total_retrieved() property ¶
Get the total number of objects this iterator has retrieved.
Source code in naff/models/misc/iterator.py
39 40 41 42 | |
add_object(obj) async ¶
Add an object to iterator's queue.
Source code in naff/models/misc/iterator.py
44 45 46 | |
fetch() async abstractmethod ¶
Fetch additional objects.
Your implementation of this method must return a list of objects. If no more objects are available, raise QueueEmpty
Returns:
| Type | Description |
|---|---|
list | List of objects |
Raises:
| Type | Description |
|---|---|
QueueEmpty | when no more objects are available. |
Source code in naff/models/misc/iterator.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
flatten() async ¶
Flatten this iterator into a list of objects.
Source code in naff/models/misc/iterator.py
85 86 87 | |
search(target_id) async ¶
Search the iterator for an object with the given ID.
Source code in naff/models/misc/iterator.py
89 90 91 92 93 94 95 96 97 98 99 | |
API¶
ConnectionState ¶
Source code in naff/api/gateway/state.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
client: Client class-attribute ¶
The bot's client
intents: Intents class-attribute ¶
The event intents in use
shard_id: int class-attribute ¶
The shard ID of this state
gateway: Absent[GatewayClient] = MISSING class-attribute ¶
The websocket connection for the Discord Gateway.
start_time: Absent[datetime] = MISSING class-attribute ¶
The DateTime the bot started at
gateway_url: str = MISSING class-attribute ¶
The URL that the gateway should connect to.
gateway_started: asyncio.Event = asyncio.Event() class-attribute ¶
Event to check if the gateway has been started.
latency() property ¶
Returns the latency of the websocket connection.
Source code in naff/api/gateway/state.py
49 50 51 52 | |
average_latency() property ¶
Returns the average latency of the websocket connection.
Source code in naff/api/gateway/state.py
54 55 56 57 | |
presence() property ¶
Returns the presence of the bot.
Source code in naff/api/gateway/state.py
59 60 61 62 63 64 65 | |
start() async ¶
Connect to the Discord Gateway.
Source code in naff/api/gateway/state.py
67 68 69 70 71 72 73 74 75 76 77 78 79 | |
stop() async ¶
Disconnect from the Discord Gateway.
Source code in naff/api/gateway/state.py
81 82 83 84 85 86 87 88 89 90 91 92 | |
clear_ready() ¶
Clear the ready event.
Source code in naff/api/gateway/state.py
94 95 96 97 | |
change_presence(status=Status.ONLINE, activity=MISSING) async ¶
Change the bots presence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status | Optional[Union[str, Status]] | The status for the bot to be. i.e. online, afk, etc. | Status.ONLINE |
activity | Absent[Union[Activity, str]] | The activity for the bot to be displayed as doing. | MISSING |
Note
Bots may only be playing streaming listening watching or competing, other activity types are likely to fail.
Source code in naff/api/gateway/state.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
get_voice_state(guild_id) ¶
Get the bot's voice state for a guild.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id | Snowflake_Type | The target guild's id. | required |
Returns:
| Type | Description |
|---|---|
Optional[ActiveVoiceState] | The bot's voice state for the guild if connected, otherwise None. |
Source code in naff/api/gateway/state.py
182 183 184 185 186 187 188 189 190 191 192 193 | |
voice_connect(guild_id, channel_id, muted=False, deafened=False) async ¶
Connect to a voice channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id | Snowflake_Type | id of the guild the voice channel is in. | required |
channel_id | Snowflake_Type | id of the voice channel client wants to join. | required |
muted | bool | Whether the bot should be muted when connected. | False |
deafened | bool | Whether the bot should be deafened when connected. | False |
Returns:
| Type | Description |
|---|---|
ActiveVoiceState | The new active voice state on successfully connection. |
Source code in naff/api/gateway/state.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
This file outlines the interaction between naff and Discord's Gateway API.
GatewayClient ¶
Bases: WebsocketClient
Abstraction over one gateway connection.
Multiple WebsocketClient instances can be used to implement same-process sharding.
Attributes:
| Name | Type | Description |
|---|---|---|
sequence | The sequence of this connection | |
session_id | The session ID of this connection |
Source code in naff/api/gateway/gateway.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
average_latency() property ¶
Get the average latency of the connection.
Source code in naff/api/gateway/gateway.py
131 132 133 134 135 136 137 | |
run() async ¶
Start receiving events from the websocket.
Source code in naff/api/gateway/gateway.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
close() ¶
Shutdown the websocket connection.
Source code in naff/api/gateway/gateway.py
243 244 245 | |
change_presence(activity=None, status=Status.ONLINE, since=None) async ¶
Update the bot's presence status.
Source code in naff/api/gateway/gateway.py
295 296 297 298 299 300 301 302 303 304 305 | |
voice_state_update(guild_id, channel_id, muted=False, deafened=False) async ¶
Update the bot's voice state.
Source code in naff/api/gateway/gateway.py
339 340 341 342 343 344 345 346 347 | |
VoiceGateway ¶
Bases: WebsocketClient
Source code in naff/api/voice/voice_gateway.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
run() async ¶
Start receiving events from the websocket.
Source code in naff/api/voice/voice_gateway.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
establish_voice_socket() async ¶
Establish the socket connection to discord
Source code in naff/api/voice/voice_gateway.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
generate_packet(data) ¶
Generate a packet to be sent to the voice socket.
Source code in naff/api/voice/voice_gateway.py
274 275 276 277 278 279 280 281 282 283 284 | |
send_packet(data, encoder, needs_encode=True) ¶
Send a packet to the voice socket
Source code in naff/api/voice/voice_gateway.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
speaking(is_speaking=True) async ¶
Tell the gateway if we're sending audio or not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_speaking | bool | If we're sending audio or not | True |
Source code in naff/api/voice/voice_gateway.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
set_new_voice_server(payload) ¶
Set a new voice server to connect to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload | dict | New voice server connection data | required |
Source code in naff/api/voice/voice_gateway.py
351 352 353 354 355 356 357 358 359 360 361 362 | |
This file handles the interaction with discords http endpoints.
GlobalLock ¶
Source code in naff/api/http/http_client.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
calls_remaining() property ¶
Returns the amount of calls remaining.
Source code in naff/api/http/http_client.py
52 53 54 55 | |
reset_calls() ¶
Resets the calls to the max amount.
Source code in naff/api/http/http_client.py
57 58 59 60 | |
set_reset_time(delta) ¶
Sets the reset time to the current time + delta.
To be called if a 429 is received.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delta | float | The time to wait before resetting the calls. | required |
Source code in naff/api/http/http_client.py
62 63 64 65 66 67 68 69 70 71 | |
wait() async ¶
Throttles calls to prevent hitting the global rate limit.
Source code in naff/api/http/http_client.py
73 74 75 76 77 78 79 80 81 | |
BucketLock ¶
Manages the ratelimit for each bucket
Source code in naff/api/http/http_client.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
locked() property ¶
Return True if lock is acquired.
Source code in naff/api/http/http_client.py
100 101 102 103 | |
unlock() ¶
Unlock this bucket.
Source code in naff/api/http/http_client.py
105 106 107 | |
ingest_ratelimit_header(header) ¶
Ingests a discord rate limit header to configure this bucket lock.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header | CIMultiDictProxy | A header from a http response | required |
Source code in naff/api/http/http_client.py
109 110 111 112 113 114 115 116 117 118 119 | |
blind_defer_unlock() async ¶
Unlocks the BucketLock but doesn't wait for completion.
Source code in naff/api/http/http_client.py
121 122 123 124 125 | |
defer_unlock(reset_after=None) async ¶
Unlocks the BucketLock after a specified delay.
Source code in naff/api/http/http_client.py
127 128 129 130 131 | |
HTTPClient ¶
Bases: BotRequests, ChannelRequests, EmojiRequests, GuildRequests, InteractionRequests, MemberRequests, MessageRequests, ReactionRequests, StickerRequests, ThreadRequests, UserRequests, WebhookRequests, ScheduledEventsRequests
A http client for sending requests to the Discord API.
Source code in naff/api/http/http_client.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | |
get_ratelimit(route) ¶
Get a route's rate limit bucket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route | Route | The route to fetch the ratelimit bucket for | required |
Returns:
| Type | Description |
|---|---|
BucketLock | The BucketLock object for this route |
Source code in naff/api/http/http_client.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
ingest_ratelimit(route, header, bucket_lock) ¶
Ingests a ratelimit header from discord to determine ratelimit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route | Route | The route we're ingesting ratelimit for | required |
header | CIMultiDictProxy | The rate limit header in question | required |
bucket_lock | BucketLock | The rate limit bucket for this route | required |
Source code in naff/api/http/http_client.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
request(route, payload=None, files=None, reason=None, params=None, **kwargs) async ¶
Make a request to discord.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route | Route | The route to take | required |
payload | list | dict | None | The payload for this request | None |
files | list[UPLOADABLE_TYPE] | None | The files to send with this request | None |
reason | str | None | Attach a reason to this request, used for audit logs | None |
Source code in naff/api/http/http_client.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
login(token) async ¶
"Login" to the gateway, basically validates the token and grabs user data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token | str | the token to use | required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | The currently logged in bot's data |
Source code in naff/api/http/http_client.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
close() async ¶
Close the session.
Source code in naff/api/http/http_client.py
401 402 403 404 | |
get_gateway() async ¶
Gets the gateway url.
Returns:
| Type | Description |
|---|---|
str | The gateway url |
Source code in naff/api/http/http_client.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
websocket_connect(url) async ¶
Connect to the websocket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url | str | the url to connect to | required |
Source code in naff/api/http/http_client.py
428 429 430 431 432 433 434 435 436 437 438 | |
Voice¶
AudioBuffer ¶
Source code in naff/api/voice/audio.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
extend(data) ¶
Extend the buffer with additional data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data | bytes | The data to add | required |
Source code in naff/api/voice/audio.py
26 27 28 29 30 31 32 33 34 | |
read(total_bytes) ¶
Read total_bytes bytes of audio from the buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
total_bytes | int | Amount of bytes to read. | required |
Returns:
| Type | Description |
|---|---|
bytearray | Desired amount of bytes |
Source code in naff/api/voice/audio.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
BaseAudio ¶
Bases: ABC
Base structure of the audio.
Source code in naff/api/voice/audio.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
locked_stream: bool class-attribute ¶
Prevents the audio task from closing automatically when no data is received.
needs_encode: bool class-attribute ¶
Does this audio data need encoding with opus?
bitrate: Optional[int] class-attribute ¶
Optionally specify a specific bitrate to encode this audio data with
cleanup() ¶
A method to optionally cleanup after this object is no longer required.
Source code in naff/api/voice/audio.py
69 70 71 | |
audio_complete() property ¶
A property to tell the player if more audio is expected.
Source code in naff/api/voice/audio.py
73 74 75 76 | |
read(frame_size) abstractmethod ¶
Reads frame_size ms of audio from source.
Returns:
| Type | Description |
|---|---|
bytes | bytes of audio |
Source code in naff/api/voice/audio.py
78 79 80 81 82 83 84 85 86 | |
Audio ¶
Bases: BaseAudio
Audio for playing from file or URL.
Source code in naff/api/voice/audio.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
audio_complete() property ¶
Uses the state of the subprocess to determine if more audio is coming
Source code in naff/api/voice/audio.py
129 130 131 132 133 134 135 | |
pre_buffer(duration=None) ¶
Start pre-buffering the audio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duration | None | float | The duration of audio to pre-buffer. | None |
Source code in naff/api/voice/audio.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
read(frame_size) ¶
Reads frame_size bytes of audio from the buffer.
Returns:
| Type | Description |
|---|---|
bytes | bytes of audio |
Source code in naff/api/voice/audio.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
cleanup() ¶
Cleans up after this audio object.
Source code in naff/api/voice/audio.py
223 224 225 226 227 | |
AudioVolume ¶
Bases: Audio
An audio object with volume control
Source code in naff/api/voice/audio.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
volume() writable property ¶
The volume of the audio
Source code in naff/api/voice/audio.py
240 241 242 243 | |
read(frame_size) ¶
Reads frame_size ms of audio from source.
Returns:
| Type | Description |
|---|---|
bytes | bytes of audio |
Source code in naff/api/voice/audio.py
250 251 252 253 254 255 256 257 258 | |
Player ¶
Bases: threading.Thread
Source code in naff/api/voice/player.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
stop() ¶
Stop playing completely.
Source code in naff/api/voice/player.py
52 53 54 55 56 | |
resume() ¶
Resume playing.
Source code in naff/api/voice/player.py
58 59 60 61 62 | |
paused() property ¶
Is the player paused
Source code in naff/api/voice/player.py
64 65 66 67 | |
pause() ¶
Pause the player.
Source code in naff/api/voice/player.py
69 70 71 | |
stopped() property ¶
Is the player currently stopped?
Source code in naff/api/voice/player.py
73 74 75 76 | |
elapsed_time() property ¶
How many seconds of audio the player has sent.
Source code in naff/api/voice/player.py
78 79 80 81 | |
play() ¶
Start playing.
Source code in naff/api/voice/player.py
83 84 85 86 87 | |
run() ¶
The main player loop to send audio to the voice websocket.
Source code in naff/api/voice/player.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
Errors¶
NaffException ¶
Bases: Exception
Base Exception of Naff.
Source code in naff/client/errors.py
52 53 | |
BotException ¶
Bases: NaffException
An issue occurred in the client, likely user error.
Source code in naff/client/errors.py
56 57 | |
GatewayNotFound ¶
Bases: NaffException
An exception that is raised when the gateway for Discord could not be found.
Source code in naff/client/errors.py
60 61 62 63 64 | |
LoginError ¶
Bases: BotException
The bot failed to login, check your token.
Source code in naff/client/errors.py
67 68 | |
HTTPException ¶
Bases: NaffException
A HTTP request resulted in an exception.
Attributes:
| Name | Type | Description |
|---|---|---|
response | aiohttp.ClientResponse | The response of the HTTP request |
text | str | The text of the exception, could be None |
status | int | The HTTP status code |
code | int | The discord error code, if one is provided |
route | Route | The HTTP route that was used |
Source code in naff/client/errors.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
search_for_message(errors, lookup=None) staticmethod ¶
Search the exceptions error dictionary for a message explaining the issue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
errors | dict | The error dictionary of the http exception | required |
lookup | Optional[dict] | A lookup dictionary to use to convert indexes into named items | None |
Returns:
| Type | Description |
|---|---|
list[str] | A list of parsed error strings found |
Source code in naff/client/errors.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
DiscordError ¶
Bases: HTTPException
A discord-side error.
Source code in naff/client/errors.py
174 175 | |
BadRequest ¶
Bases: HTTPException
A bad request was made.
Source code in naff/client/errors.py
178 179 | |
Forbidden ¶
Bases: HTTPException
You do not have access to this.
Source code in naff/client/errors.py
182 183 | |
NotFound ¶
Bases: HTTPException
This resource could not be found.
Source code in naff/client/errors.py
186 187 | |
RateLimited ¶
Bases: HTTPException
Discord is rate limiting this application.
Source code in naff/client/errors.py
190 191 | |
TooManyChanges ¶
Bases: NaffException
You have changed something too frequently.
Source code in naff/client/errors.py
194 195 | |
WebSocketClosed ¶
Bases: NaffException
The websocket was closed.
Source code in naff/client/errors.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
VoiceWebSocketClosed ¶
Bases: NaffException
The voice websocket was closed.
Source code in naff/client/errors.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
WebSocketRestart ¶
Bases: NaffException
The websocket closed, and is safe to restart.
Source code in naff/client/errors.py
252 253 254 255 256 257 258 259 | |
ExtensionException ¶
Bases: BotException
An error occurred with an extension.
Source code in naff/client/errors.py
262 263 | |
ExtensionNotFound ¶
Bases: ExtensionException
The desired extension was not found.
Source code in naff/client/errors.py
266 267 | |
ExtensionLoadException ¶
Bases: ExtensionException
An error occurred loading an extension.
Source code in naff/client/errors.py
270 271 | |
CommandException ¶
Bases: BotException
An error occurred trying to execute a command.
Source code in naff/client/errors.py
274 275 | |
CommandOnCooldown ¶
Bases: CommandException
A command is on cooldown, and was attempted to be executed.
Attributes:
| Name | Type | Description |
|---|---|---|
command | BaseCommand | The command that is on cooldown |
cooldown | CooldownSystem | The cooldown system |
Source code in naff/client/errors.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
MaxConcurrencyReached ¶
Bases: CommandException
A command has exhausted the max concurrent requests.
Source code in naff/client/errors.py
295 296 297 298 299 300 301 302 | |
CommandCheckFailure ¶
Bases: CommandException
A command check failed.
Attributes:
| Name | Type | Description |
|---|---|---|
command | BaseCommand | The command that's check failed |
check | Callable[..., Coroutine] | The check that failed |
Source code in naff/client/errors.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
BadArgument ¶
Bases: CommandException
A prefixed command encountered an invalid argument.
Source code in naff/client/errors.py
321 322 323 324 325 326 327 328 329 | |
MessageException ¶
Bases: BotException
A message operation encountered an exception.
Source code in naff/client/errors.py
332 333 | |
EmptyMessageException ¶
Bases: MessageException
You have attempted to send a message without any content or embeds
Source code in naff/client/errors.py
336 337 | |
EphemeralEditException ¶
Bases: MessageException
Your bot attempted to edit an ephemeral message. This is not possible.
Its worth noting you can edit an ephemeral message with component's edit_origin method.
Source code in naff/client/errors.py
340 341 342 343 344 345 346 347 348 349 350 | |
ThreadException ¶
Bases: BotException
A thread operation encountered an exception.
Source code in naff/client/errors.py
353 354 | |
ThreadOutsideOfGuild ¶
Bases: ThreadException
A thread was attempted to be created outside of a guild.
Source code in naff/client/errors.py
357 358 359 360 361 | |
InteractionException ¶
Bases: BotException
An error occurred with an interaction.
Source code in naff/client/errors.py
364 365 | |
InteractionMissingAccess ¶
Bases: InteractionException
The bot does not have access to the specified scope.
Source code in naff/client/errors.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
AlreadyDeferred ¶
Bases: BotException
An interaction was already deferred, and you attempted to defer it again.
Source code in naff/client/errors.py
385 386 | |
ForeignWebhookException ¶
Bases: NaffException
Raised when you attempt to send using a webhook you did not create.
Source code in naff/client/errors.py
389 390 | |
EventLocationNotProvided ¶
Bases: BotException
Raised when you have entity_type external and no location is provided.
Source code in naff/client/errors.py
393 394 | |
VoiceAlreadyConnected ¶
Bases: BotException
Raised when you attempt to connect a voice channel that is already connected.
Source code in naff/client/errors.py
397 398 399 400 401 | |
VoiceNotConnected ¶
Bases: BotException
Raised when you attempt to connect a voice channel that is not connected.
Source code in naff/client/errors.py
404 405 406 407 408 | |
VoiceConnectionTimeout ¶
Bases: NaffException
Raised when the bot fails to connect to a voice channel.
Source code in naff/client/errors.py
411 412 413 414 415 | |
Events¶
These are events dispatched by Discord. This is intended as a reference so you know what data to expect for each event.
Example Usage:
The event classes outlined here are in CamelCase to comply with Class naming convention, however the event names are actually in lower_case_with_underscores so your listeners should be named as following:
1 2 3 4 5 6 7 8 9 | |
Warning
While all of these events are documented, not all of them are used, currently.
RawGatewayEvent ¶
Bases: BaseEvent
An event dispatched from the gateway.
Holds the raw dict that the gateway dispatches
Source code in naff/api/events/discord.py
104 105 106 107 108 109 110 111 112 113 114 | |
data: dict = field(factory=dict) class-attribute ¶
Raw Data from the gateway
AutoModExec ¶
Bases: BaseEvent
Dispatched when an auto modation action is executed
Source code in naff/api/events/discord.py
117 118 119 120 121 122 123 | |
AutoModUpdated ¶
Bases: AutoModCreated
Dispatched when an auto mod rule is modified
Source code in naff/api/events/discord.py
132 133 134 135 136 | |
AutoModDeleted ¶
Bases: AutoModCreated
Dispatched when an auto mod rule is deleted
Source code in naff/api/events/discord.py
139 140 141 142 143 | |
ChannelCreate ¶
Bases: BaseEvent
Dispatched when a channel is created.
Source code in naff/api/events/discord.py
146 147 148 149 150 | |
ChannelUpdate ¶
Bases: BaseEvent
Dispatched when a channel is updated.
Source code in naff/api/events/discord.py
153 154 155 156 157 158 159 160 | |
ChannelDelete ¶
Bases: ChannelCreate
Dispatched when a channel is deleted.
Source code in naff/api/events/discord.py
163 164 165 | |
ChannelPinsUpdate ¶
Bases: ChannelCreate
Dispatched when a channel's pins are updated.
Source code in naff/api/events/discord.py
168 169 170 171 172 173 | |
last_pin_timestamp: Timestamp = field() class-attribute ¶
The time at which the most recent pinned message was pinned
ThreadCreate ¶
Bases: BaseEvent
Dispatched when a thread is created.
Source code in naff/api/events/discord.py
176 177 178 179 180 | |
ThreadUpdate ¶
Bases: ThreadCreate
Dispatched when a thread is updated.
Source code in naff/api/events/discord.py
183 184 185 | |
ThreadDelete ¶
Bases: ThreadCreate
Dispatched when a thread is deleted.
Source code in naff/api/events/discord.py
188 189 190 | |
ThreadListSync ¶
Bases: BaseEvent
Dispatched when gaining access to a channel, contains all active threads in that channel.
Source code in naff/api/events/discord.py
193 194 195 196 197 198 199 200 201 202 | |
channel_ids: Sequence[Snowflake_Type] = field() class-attribute ¶
The parent channel ids whose threads are being synced. If omitted, then threads were synced for the entire guild. This array may contain channel_ids that have no active threads as well, so you know to clear that data.
threads: List[BaseChannel] = field() class-attribute ¶
all active threads in the given channels that the current user can access
members: List[Member] = field() class-attribute ¶
all thread member objects from the synced threads for the current user, indicating which threads the current user has been added to
ThreadMemberUpdate ¶
Bases: ThreadCreate
Dispatched when the thread member object for the current user is updated.
??? info "Note from Discord" This event is documented for completeness, but unlikely to be used by most bots. For bots, this event largely is just a signal that you are a member of the thread
Source code in naff/api/events/discord.py
206 207 208 209 210 211 212 213 214 215 216 217 218 | |
member: Member = field() class-attribute ¶
The member who was added
ThreadMembersUpdate ¶
Bases: BaseEvent
Dispatched when anyone is added or removed from a thread.
Source code in naff/api/events/discord.py
221 222 223 224 225 226 227 228 229 230 231 232 | |
id: Snowflake_Type = field() class-attribute ¶
The ID of the thread
member_count: int = field(default=50) class-attribute ¶
the approximate number of members in the thread, capped at 50
added_members: List[Member] = field(factory=list) class-attribute ¶
Users added to the thread
removed_member_ids: List[Snowflake_Type] = field(factory=list) class-attribute ¶
Users removed from the thread
GuildJoin ¶
Bases: BaseEvent
Dispatched when a guild is joined, created, or becomes available.
Note
This is called multiple times during startup, check the bot is ready before responding to this.
Source code in naff/api/events/discord.py
235 236 237 238 239 240 241 242 243 244 245 246 | |
guild: Guild = field() class-attribute ¶
The guild that was created
GuildUpdate ¶
Bases: BaseEvent
Dispatched when a guild is updated.
Source code in naff/api/events/discord.py
249 250 251 252 253 254 255 256 | |
GuildLeft ¶
Bases: BaseEvent, GuildEvent
Dispatched when a guild is left.
Source code in naff/api/events/discord.py
259 260 261 262 263 264 | |
guild: Optional[Guild] = field(default=MISSING) class-attribute ¶
The guild, if it was cached
GuildUnavailable ¶
Bases: BaseEvent, GuildEvent
Dispatched when a guild is not available.
Source code in naff/api/events/discord.py
267 268 269 270 271 272 | |
guild: Optional[Guild] = field(default=MISSING) class-attribute ¶
The guild, if it was cached
BanCreate ¶
Bases: BaseEvent, GuildEvent
Dispatched when someone was banned from a guild.
Source code in naff/api/events/discord.py
275 276 277 278 279 | |
BanRemove ¶
Bases: BanCreate
Dispatched when a users ban is removed.
Source code in naff/api/events/discord.py
282 283 284 | |
GuildEmojisUpdate ¶
Bases: BaseEvent, GuildEvent
Dispatched when a guild's emojis are updated.
Source code in naff/api/events/discord.py
287 288 289 290 291 292 293 294 | |
before: List[CustomEmoji] = field(factory=list) class-attribute ¶
List of emoji before this event. Only includes emojis that were cached. To enable the emoji cache (and this field), start your bot with Client(enable_emoji_cache=True)
after: List[CustomEmoji] = field(factory=list) class-attribute ¶
List of emoji after this event
GuildStickersUpdate ¶
Bases: BaseEvent, GuildEvent
Dispatched when a guild's stickers are updated.
Source code in naff/api/events/discord.py
297 298 299 300 301 302 | |
stickers: List[Sticker] = field(factory=list) class-attribute ¶
List of stickers from after this event
MemberAdd ¶
Bases: BaseEvent, GuildEvent
Dispatched when a member is added to a guild.
Source code in naff/api/events/discord.py
305 306 307 308 309 | |
MemberRemove ¶
Bases: MemberAdd
Dispatched when a member is removed from a guild.
Source code in naff/api/events/discord.py
312 313 314 315 316 317 318 | |
MemberUpdate ¶
Bases: BaseEvent, GuildEvent
Dispatched when a member is updated.
Source code in naff/api/events/discord.py
321 322 323 324 325 326 327 328 | |
RoleCreate ¶
Bases: BaseEvent, GuildEvent
Dispatched when a role is created.
Source code in naff/api/events/discord.py
331 332 333 334 335 336 | |
role: Role = field() class-attribute ¶
The created role
RoleUpdate ¶
Bases: BaseEvent, GuildEvent
Dispatched when a role is updated.
Source code in naff/api/events/discord.py
339 340 341 342 343 344 345 346 | |
RoleDelete ¶
Bases: BaseEvent, GuildEvent
Dispatched when a guild role is deleted.
Source code in naff/api/events/discord.py
349 350 351 352 353 354 355 356 | |
GuildMembersChunk ¶
Bases: BaseEvent, GuildEvent
Sent in response to Guild Request Members.
You can use the chunk_index and chunk_count to calculate how many chunks are left for your request.
Source code in naff/api/events/discord.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
chunk_index: int = field() class-attribute ¶
The chunk index in the expected chunks for this response (0 <= chunk_index < chunk_count)
chunk_count: int = field() class-attribute ¶
the total number of expected chunks for this response
presences: List = field() class-attribute ¶
if passing true to REQUEST_GUILD_MEMBERS, presences of the returned members will be here
nonce: str = field() class-attribute ¶
The nonce used in the request, if any
members: List[Member] = field(factory=list) class-attribute ¶
A list of members
IntegrationCreate ¶
Bases: BaseEvent
Dispatched when a guild integration is created.
Source code in naff/api/events/discord.py
381 382 383 384 385 | |
IntegrationUpdate ¶
Bases: IntegrationCreate
Dispatched when a guild integration is updated.
Source code in naff/api/events/discord.py
388 389 390 | |
IntegrationDelete ¶
Bases: BaseEvent, GuildEvent
Dispatched when a guild integration is deleted.
Source code in naff/api/events/discord.py
393 394 395 396 397 398 399 400 | |
InviteCreate ¶
Bases: BaseEvent
Dispatched when a guild invite is created.
Source code in naff/api/events/discord.py
403 404 405 406 407 | |
InviteDelete ¶
Bases: InviteCreate
Dispatched when an invite is deleted.
Source code in naff/api/events/discord.py
410 411 412 | |
MessageCreate ¶
Bases: BaseEvent
Dispatched when a message is created.
Source code in naff/api/events/discord.py
415 416 417 418 419 | |
MessageUpdate ¶
Bases: BaseEvent
Dispatched when a message is edited.
Source code in naff/api/events/discord.py
422 423 424 425 426 427 428 429 | |
MessageDelete ¶
Bases: BaseEvent
Dispatched when a message is deleted.
Source code in naff/api/events/discord.py
432 433 434 435 436 | |
MessageDeleteBulk ¶
Bases: BaseEvent, GuildEvent
Dispatched when multiple messages are deleted at once.
Source code in naff/api/events/discord.py
439 440 441 442 443 444 445 446 | |
MessageReactionAdd ¶
Bases: BaseEvent
Dispatched when a reaction is added to a message.
Source code in naff/api/events/discord.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
reaction_count() property ¶
Times the emoji in the event has been used to react
Source code in naff/api/events/discord.py
461 462 463 464 465 466 | |
MessageReactionRemove ¶
Bases: MessageReactionAdd
Dispatched when a reaction is removed.
Source code in naff/api/events/discord.py
469 470 471 | |
MessageReactionRemoveAll ¶
Bases: BaseEvent, GuildEvent
Dispatched when all reactions are removed from a message.
Source code in naff/api/events/discord.py
474 475 476 477 478 479 | |
message: Message = field() class-attribute ¶
The message that was reacted to
PresenceUpdate ¶
Bases: BaseEvent
A user's presence has changed.
Source code in naff/api/events/discord.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
user: User = field() class-attribute ¶
The user in question
status: str = field() class-attribute ¶
'Either idle, dnd, online, or offline'
activities: List[Activity] = field() class-attribute ¶
The users current activities
client_status: dict = field() class-attribute ¶
What platform the user is reported as being on
guild_id: Snowflake_Type = field() class-attribute ¶
The guild this presence update was dispatched from
StageInstanceCreate ¶
Bases: BaseEvent
Dispatched when a stage instance is created.
Source code in naff/api/events/discord.py
498 499 500 501 502 | |
StageInstanceDelete ¶
Bases: StageInstanceCreate
Dispatched when a stage instance is deleted.
Source code in naff/api/events/discord.py
505 506 507 | |
StageInstanceUpdate ¶
Bases: StageInstanceCreate
Dispatched when a stage instance is updated.
Source code in naff/api/events/discord.py
510 511 512 | |
TypingStart ¶
Bases: BaseEvent
Dispatched when a user starts typing.
Source code in naff/api/events/discord.py
515 516 517 518 519 520 521 522 523 524 525 526 | |
author: Union[User, Member] = field() class-attribute ¶
The user who started typing
channel: BaseChannel = field() class-attribute ¶
The channel typing is in
guild: Guild = field() class-attribute ¶
The ID of the guild this typing is in
timestamp: Timestamp = field() class-attribute ¶
unix time (in seconds) of when the user started typing
WebhooksUpdate ¶
Bases: BaseEvent, GuildEvent
Dispatched when a guild channel webhook is created, updated, or deleted.
Source code in naff/api/events/discord.py
529 530 531 532 533 534 535 | |
channel_id: Snowflake_Type = field() class-attribute ¶
The ID of the webhook was updated
InteractionCreate ¶
Bases: BaseEvent
Dispatched when a user uses an Application Command.
Source code in naff/api/events/discord.py
538 539 540 541 542 | |
ModalResponse ¶
Bases: BaseEvent
Dispatched when a modal receives a response
Source code in naff/api/events/discord.py
545 546 547 548 549 550 | |
context: ModalContext = field() class-attribute ¶
The context data of the modal
VoiceStateUpdate ¶
Bases: BaseEvent
Dispatched when a user joins/leaves/moves voice channels.
Source code in naff/api/events/discord.py
553 554 555 556 557 558 559 560 | |
before: Optional[VoiceState] = field() class-attribute ¶
The voice state before this event was created or None if the user was not in a voice channel
after: Optional[VoiceState] = field() class-attribute ¶
The voice state after this event was created or None if the user is no longer in a voice channel
These are events dispatched by the client. This is intended as a reference so you know what data to expect for each event.
Example Usage:
The event classes outlined here are in CamelCase to comply with Class naming convention, however the event names are actually in lower_case_with_underscores so your listeners should be named as following:
1 2 3 4 5 6 7 8 9 | |
Warning
While all of these events are documented, not all of them are used, currently.
BaseEvent ¶
A base event that all other events inherit from.
Source code in naff/api/events/internal.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
override_name: str = field(kw_only=True, default=None) class-attribute ¶
Custom name of the event to be used when dispatching.
bot: Client = field(kw_only=True, default=MISSING) class-attribute ¶
The client instance that dispatched this event.
resolved_name() property ¶
The name of the event, defaults to the class name if not overridden.
Source code in naff/api/events/internal.py
68 69 70 71 72 | |
listen(coro, client) classmethod ¶
A shortcut for creating a listener for this event
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coro | Callable[..., Coroutine] | The coroutine to call when the event is triggered. | required |
client | Client | The client instance to listen to. | required |
Example Usage:
1 2 3 4 5 6 | |
Returns:
| Type | Description |
|---|---|
Listener | A listener object. |
Source code in naff/api/events/internal.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
GuildEvent ¶
A base event that adds guild_id.
Source code in naff/api/events/internal.py
101 102 103 104 105 106 107 108 109 110 | |
guild() property ¶
Guild related to event
Source code in naff/api/events/internal.py
107 108 109 110 | |
Login ¶
Bases: BaseEvent
The bot has just logged in.
Source code in naff/api/events/internal.py
113 114 115 | |
Connect ¶
Bases: BaseEvent
The bot is now connected to the discord Gateway.
Source code in naff/api/events/internal.py
118 119 120 | |
Resume ¶
Bases: BaseEvent
The bot has resumed its connection to the discord Gateway.
Source code in naff/api/events/internal.py
123 124 125 | |
Disconnect ¶
Bases: BaseEvent
The bot has just disconnected.
Source code in naff/api/events/internal.py
128 129 130 | |
ShardConnect ¶
Bases: Connect
A shard just connected to the discord Gateway.
Source code in naff/api/events/internal.py
133 134 135 136 137 | |
ShardDisconnect ¶
Bases: Disconnect
A shard just disconnected.
Source code in naff/api/events/internal.py
140 141 142 143 144 | |
Startup ¶
Bases: BaseEvent
The client is now ready for the first time.
Use this for tasks you want to do upon login, instead of ready, as this will only be called once.
Source code in naff/api/events/internal.py
147 148 149 150 151 152 153 154 155 | |
Ready ¶
Bases: BaseEvent
The client is now ready.
Note
Don't use this event for things that must only happen once, on startup, as this event may be called multiple times. Instead, use the Startup event
Source code in naff/api/events/internal.py
158 159 160 161 162 163 164 165 166 167 | |
WebsocketReady ¶
Bases: BaseEvent
The gateway has reported that it is ready.
Source code in naff/api/events/internal.py
170 171 172 173 174 | |
Component ¶
Bases: BaseEvent
Dispatched when a user uses a Component.
Source code in naff/api/events/internal.py
177 178 179 180 181 | |
Button ¶
Bases: Component
Dispatched when a user uses a Button.
Source code in naff/api/events/internal.py
184 185 186 | |
Select ¶
Bases: Component
Dispatched when a user uses a Select.
Source code in naff/api/events/internal.py
189 190 191 | |
Error ¶
Bases: BaseEvent
Dispatched when the library encounters an error.
Source code in naff/api/events/internal.py
194 195 196 197 198 199 200 201 202 | |